:root {
  --color-correct: #6aaa64;
  --color-present: #c9b458;
  --color-absent: #787c7e;
  --color-background: #dadada;
  --color-side-background: #7c7c7c;
  --board-background: #e9e9e9;
  --color-text: #1a1a1b;
  --keyboard-text: #1a1a1b;
  --keyboard-bg: #d3d6da;
  --tile-border: #d3d6da;
  --keyboard-tile-border: #8b8b8b;
  --header-border-bottom: #a7a7a7;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
}

body {
  background-color: var(--color-background);
  color: var(--color-text);
  display: flex;
  height: 100vh;
  justify-content: center;
}


.main-container {
  display: flex;
  flex-direction: row;
  /* align-items: center; */
  align-items: stretch;
  justify-content: center;
  /* height: 100%; */
  height: 100vh;
  overflow: hidden;
  width: 100%;
}

.side-container {
  background-color: var(--color-side-background);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 2vw;
}

#left-container {
  align-items: flex-end;
}

#right-container {
  align-items: flex-start;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto; /* Add scrolling if content exceeds height */
  padding: 10px;
  justify-content: space-evenly;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--header-border-bottom);
  width: 100%;
}

h1 {
  font-weight: 700;
  font-size: 36px;
  letter-spacing: 0.2rem;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.message-container {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  min-width: 280px;
  max-width: 80%;
  padding: 12px 18px;
  font-weight: bold;
  text-align: center;
  border-radius: 8px;
  color: #721c24;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.message-error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
}

.message-warning {
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.message-hidden {
  opacity: 0;
}

#message-container {
  height: 30px;
  margin: 10px 0;
  font-weight: bold;
}

#new-game-btn {
  padding: 8px 16px;
  background-color: var(--color-correct);
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 10px;
}

#board-container {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  padding: 10px;
  margin: 20px 0;
  width: 100%;
  max-height: 60vh; /* Limit maximum height */
}

#board {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  /* grid-template-rows: repeat(6, 1fr);
  grid-gap: 5px; */
  padding: 10px;
  box-sizing: border-box;
  /* width: 350px;
  height: 420px; */
  width: 100%;
  height: 100%;
  background-color: var(--board-background);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  overflow: auto;
}

.row {
  display: flex;
  /* grid-template-columns: repeat(5, 1fr); */
}

.tile {
  position: relative;
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  /* font-size: 2rem; */
  line-height: 1;
  font-weight: bold;
  vertical-align: middle;
  border: 2px solid var(--tile-border);
  text-transform: uppercase;
  user-select: none;
  aspect-ratio: 1 / 1;
  background-color: white;
  /* min-height: 60px; */
  /* max-height: 80px;
  max-width: 80px; */
  margin: 1px;
}
/* Then style the repeat indicator */
.tile .repeat {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.7rem;
  font-weight: bold;
  color: white;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none; /* Prevents it from interfering with clicks */
  z-index: 1; /* Ensures it appears above the tile content */
}

/* Style for the direction indicator */
.tile .direction {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 1rem;
  font-weight: bold;
  color: white;
  background-color: rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tile .direction.left { transform: rotate(180deg); }
.tile .direction.right { transform: rotate(0deg); }

.tile.flip {
  animation: 0.5s linear flipping;
}

@keyframes flipping {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

.tile.correct {
  background-color: var(--color-correct);
  color: white;
  border-color: var(--color-correct);
}

.tile.present {
  background-color: var(--color-present);
  color: white;
  border-color: var(--color-present);
}

.tile.absent {
  background-color: var(--color-absent);
  color: white;
  border-color: var(--color-absent);
}

#keyboard-container {
  width: 100%;
  margin: 0 auto 8px;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0 auto 8px;
}

.keyboard-row button {
  font-family: inherit;
  font-weight: bold;
  border: 1px solid var(--keyboard-tile-border);
  padding: 0;
  margin: 0 6px 0 0;
  height: 58px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  background-color: var(--keyboard-bg);
  color: var(--keyboard-text);
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-transform: uppercase;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.3);
}

.keyboard-row button.wide-button {
  flex: 1.5;
}

.spacer {
  flex: 0.5;
}

.keyboard-row button:last-of-type {
  margin: 0;
}

.keyboard-row button.correct {
  background-color: var(--color-correct);
  color: white;
}

.keyboard-row button.present {
  background-color: var(--color-present);
  color: white;
}

.keyboard-row button.absent {
  background-color: var(--color-absent);
  color: white;
}

.cur-upgrade-tier1 {
  border: 4px solid #4040FF;
  background: linear-gradient(to bottom, #4040ffc4, #4040FF);
}

.cur-upgrade-tier2 {
  border: 4px solid #40C040;
  background: linear-gradient(to bottom, #40d75270, #40C040);
}

.cur-upgrade-tier3 {
  border: 4px solid #FFA500;
  background: linear-gradient(to bottom, #ffa50082, #FFA500);
}

.cur-debuff-tier1, .cur-debuff-tier2, .cur-debuff-tier3 {
  border: 4px solid #FF4040;
  background: linear-gradient(to bottom, #ff4040a8, #FF4040);
  color: white;
}

.cur-upgrade {
  /* margin: 10px 0px 10px 10px; */
  border-radius: 10px;
  padding: 0.3em 0.5em;
  line-height: 1.2;
  white-space: nowrap;
  width: 100%;
  text-align: center;
  color: white;
  font-weight: bold;
}

#num-matches-info {
  display: none;
}

#abilities-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 16px;
  margin: 15px 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ability-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ability-square {
  width: 60px;
  height: 60px;
  background: linear-gradient(145deg, rgba(60, 60, 60, 0.4), rgba(30, 30, 30, 0.6));
  border: 2px solid var(--keyboard-tile-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

/* Add subtle glow effect based on ability type */
.ability-square[data-ability="hint"] {
  border-color: rgba(255, 215, 0, 0.6);
}

.ability-square[data-ability="darken"] {
  border-color: rgba(138, 43, 226, 0.6);
}

.ability-square[data-ability="repeats"] {
  border-color: rgba(30, 144, 255, 0.6);
}

.ability-square[data-ability="accept-non-words"] {
  border-color: rgba(50, 205, 50, 0.6);
}

/* Add a subtle animated background pattern */
.ability-square::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.ability-square:hover:not(.disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.ability-square:hover:not(.disabled)::after {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.12) 0%, transparent 70%);
  animation: pulse 2s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.ability-square.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(145deg, rgba(60, 60, 60, 0.2), rgba(30, 30, 30, 0.3));
  box-shadow: none;
}

.ability-count {
  font-weight: bold;
  color: var(--color-text);
  font-size: 1.1em;
  margin-top: 5px;
}

/* Ability-specific icons can be added here */
.ability-square[data-ability="hint"]::before {
  content: "💡";
  font-size: 1.5em;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.ability-square[data-ability="darken"]::before {
  content: "🌙";
  font-size: 1.5em;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.ability-square[data-ability="accept-non-words"]::before {
  content: "🔓";
  font-size: 1.5em;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.ability-square[data-ability="repeats"]::before {
  content: "🔄";
  font-size: 1.5em;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* .ability-square[data-ability="bonus"]::before {
  content: "⭐";
  font-size: 1.5em;
}

.ability-square[data-ability="skip"]::before {
  content: "⏭️";
  font-size: 1.5em;
} */

/* Hint words styling */
#active-hints {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    width: 100%;
}

#active-hints h2 {
    color: #ffd700;
    font-size: 1.2em;
    margin-bottom: 10px;
    text-align: center;
}

.hint-word {
    background-color: var(--color-correct);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    margin: 5px 0;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-out;
}

/* Number repeats styling */
#repeats-info {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    width: 100%;
}

#repeats-info h2 {
    color: #ffd700;
    font-size: 1.2em;
    margin-bottom: 10px;
    text-align: center;
}

#num-repeats {
    background-color: var(--color-present);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    margin: 5px 0;
    font-weight: bold;
    text-align: center;
    font-size: 1.5em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-out;
}

/* Accept non-words styling */
#accept-non-words-info {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    width: 100%;
}

#accept-non-words-info h2 {
    color: white;
    font-size: 1.2em;
    text-align: center;
    background-color: var(--color-absent);
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-out;
    margin: 0;
}

#non-words-message {
    background-color: var(--color-absent);
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    margin: 5px 0;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}