/* OXO Tic-Tac-Toe Stylesheet
   Version: 0.4 */

@import url('https://fonts.googleapis.com/css2?family=Amaranth:ital,wght@0,400;0,700;1,400&display=swap');

@import url('../variables.css');

:root {
  /* Internal version checking variable */
  --css-version: "0.4";
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: linear-gradient(
    -45deg,
    var(--cycler-gradient-start),
    var(--cycler-gradient-mid-a),
    var(--cycler-gradient-mid-b),
    var(--cycler-gradient-end)
  );
  background-size: 320% 320%;
  background-attachment: fixed;
  background-color: #313131;
  animation: cycler-gradient 40s ease-in-out infinite;
  color: var(--panel-text);
  font-family: 'Amaranth', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(16px, 0.3vw + 15px, 18px);
  line-height: 1.6;
  padding: 0 0 32px;
}

@keyframes cycler-gradient {
  0% { background-position: 18% 50%; }
  50% { background-position: 82% 50%; }
  100% { background-position: 18% 50%; }
}

header {
  width: 95%;
  max-width: 600px;
  margin: 0.5em auto 0.8em;
  padding: 0.5em 0.7em 0.65em;
  text-align: center;
  background: var(--cycler-glass-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 20px;
  box-shadow: var(--cycler-header-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

header h1 {
  color: var(--heading-text);
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-variant: small-caps;
  font-weight: 700;
  line-height: 1.12;
}

header p {
  max-width: 75ch;
  margin: 0.35em auto 0;
  color: var(--heading-copy);
  font-size: clamp(0.9rem, 1vw + 0.7rem, 1.1rem);
  line-height: 1.35;
}

.container {
  width: 95%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
}

/* Glass-style container layout panels */
.panel {
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border: 1px solid var(--cycler-border);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
  padding: 0.9em;
}

/* ============================================================================
   SCOREBOARD PANEL
   ============================================================================ */

.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 0.8em;
}

.score-card {
  flex: 1;
  background: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  border-radius: 12px;
  padding: 0.6em;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.score-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.score-card h3 {
  font-size: 0.95rem;
  color: var(--panel-muted);
  text-transform: uppercase;
  margin-bottom: 0.2em;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.score-value {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--strong-text);
  line-height: 1;
  margin-bottom: 0.2em;
}

.indicators {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.3em;
}

.indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel-softer);
  border: 1px solid rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

/* Active win light effects */
#human-indicators .indicator-dot.active {
  background-color: var(--x-color);
  box-shadow: 0 0 8px var(--x-shadow), 0 0 2px var(--x-color);
  border-color: var(--x-color);
}

#computer-indicators .indicator-dot.active {
  background-color: var(--o-color);
  box-shadow: 0 0 8px var(--o-shadow), 0 0 2px var(--o-color);
  border-color: var(--o-color);
}

/* ============================================================================
   SETTINGS PANEL
   ============================================================================ */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.7em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
}

.field label {
  color: var(--panel-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.field select {
  height: 2.6rem;
  color: var(--field-text);
  background: var(--field-bg);
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35em 0.55em;
  cursor: pointer;
  width: 100%;
}

.field select:focus {
  outline: none;
  border-color: var(--cycler-hover);
  box-shadow: 0 0 0 3px rgba(199, 42, 147, 0.22);
}

.field select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================================
   GAME BOARD WIDGET
   ============================================================================ */

.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  margin: 0.5em auto;
  perspective: 600px;
}

.grid-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.40)  0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05)       51%,
    rgba(0, 0, 0, 0.10)      100%
  );
  box-shadow:
    inset  1px  1px 0px rgba(255, 255, 255, 0.6),
    inset -1px -1px 0px rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 10px var(--cycler-button-glow);
  border: 1px solid var(--cycler-border);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease-out,
              box-shadow       0.15s ease-out,
              transform        0.15s ease-out,
              border-color     0.15s ease-out;
  outline: none;
  font-family: 'Amaranth', sans-serif;
  user-select: none;
}

.grid-cell:hover:not(:disabled) {
  background-color: var(--cycler-button-bg-hover);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5)  0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px var(--cycler-button-glow);
}

.grid-cell:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

.grid-cell:active:not(:disabled) {
  transform: translateY(1px);
}

/* Marks */
.grid-cell span {
  display: block;
  font-size: clamp(2.5rem, 10vw, 3.8rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.2);
  animation: mark-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.mark-x {
  color: var(--x-color);
}

.mark-o {
  color: var(--o-color);
}

@keyframes mark-pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Win highlighting pulse */
.grid-cell.winning-cell {
  animation: win-pulse 0.9s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

@keyframes win-pulse {
  0% {
    transform: scale(1);
    background-color: var(--cycler-button-bg);
    border-color: var(--cycler-border);
    box-shadow: 0 0 10px var(--cycler-button-glow);
  }
  100% {
    transform: scale(1.04);
    background-color: var(--cycler-hover);
    border-color: var(--cycler-hover);
    box-shadow: 0 0 22px var(--cycler-hover);
  }
}

.winning-cell span {
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Disabled state */
.grid-cell:disabled {
  cursor: not-allowed;
}

.grid-cell:disabled:not(.winning-cell) {
  opacity: 0.9;
  background-color: var(--panel-softer);
  background-image: none;
  box-shadow: none;
}

/* ============================================================================
   STATUS BANNER
   ============================================================================ */

.status-msg-container {
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.2em;
}

.status-msg {
  padding: 0.35em 1em;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  background: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.human-turn {
  border-color: var(--x-color);
  box-shadow: 0 0 12px var(--x-shadow);
  color: var(--x-color);
}

.thinking-msg {
  border-color: var(--cycler-border);
  color: var(--panel-muted);
}

.win-x-msg {
  background-color: var(--x-color);
  color: #fff;
  border-color: var(--x-color);
  box-shadow: 0 0 15px var(--x-shadow);
}

.win-o-msg {
  background-color: var(--o-color);
  color: #fff;
  border-color: var(--o-color);
  box-shadow: 0 0 15px var(--o-shadow);
}

.draw-msg {
  background-color: var(--panel-muted);
  color: #fff;
  border-color: var(--cycler-border);
}

/* ============================================================================
   ACTIONS PANEL
   ============================================================================ */

.actions {
  display: flex;
  justify-content: center;
  gap: 0.8em;
  margin-top: 0.4em;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.4em 1em;
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  border: 1px solid var(--cycler-border);
  border-radius: 8px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.6),
    inset -1px -1px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 12px var(--cycler-button-glow);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  transition: background-color 0.15s ease-out,
              box-shadow 0.15s ease-out,
              transform 0.15s ease-out;
}

button:hover {
  background-color: var(--cycler-button-bg-hover);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  transform: translateY(1.5px);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, 0.2),
    inset -1px -1px 4px rgba(255, 255, 255, 0.1),
    0 0 15px var(--cycler-button-glow);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    inset -1px -1px 0 rgba(0, 0, 0, 0.08);
}

button:disabled:hover {
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  transform: none;
}

button:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

button.primary {
  background-color: var(--cycler-hover);
  color: #ffffff;
  border-color: var(--cycler-hover);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 14px rgba(199, 42, 147, 0.5);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.02) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.15) 100%
  );
}

button.primary:hover {
  background-color: #b01b80;
  box-shadow: 0 0 18px rgba(199, 42, 147, 0.7);
}

/* ============================================================================
   MATCH CHAMPION VICTORY BANNER
   ============================================================================ */

.match-banner {
  display: none;
  background: rgba(14, 2, 21, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--cycler-hover);
  border-radius: 20px;
  position: absolute;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1em;
  padding: 1.5em;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
  animation: banner-fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.match-banner.visible {
  display: flex;
}

@keyframes banner-fade-in {
  0% { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

.match-banner h2 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--accent-text);
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  margin-bottom: 0.1em;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.match-banner p {
  color: var(--panel-text);
  font-size: 1.2rem;
  max-width: 40ch;
}

/* ============================================================================
   CACHE WARNING BANNER
   ============================================================================ */

.cache-warning {
  display: none;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  padding: 0.5em 0.8em;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.8em;
  text-align: center;
}

.cache-warning.visible {
  display: block;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

/* ============================================================================
   THEME TOGGLE
   ============================================================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  width: fit-content;
  max-width: 95%;
  margin: 0;
  padding: 0.22em;
  color: var(--cycler-theme-text);
  background: var(--cycler-theme-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(45, 4, 82, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.theme-toggle button {
  appearance: none;
  -webkit-appearance: none;
  min-height: 1.9rem;
  padding: 0.25em 0.58em;
  color: var(--cycler-theme-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: clamp(13px, 0.45vw + 0.65rem, 16px);
  line-height: 1;
  transition: background-color 0.15s ease-out,
              border-color 0.15s ease-out,
              box-shadow 0.15s ease-out,
              transform 0.15s ease-out;
}

.theme-toggle button:hover,
.theme-toggle button:focus {
  background: var(--cycler-theme-active-bg);
  border-color: var(--cycler-glass-border);
  outline: none;
}

.theme-toggle button[aria-pressed="true"] {
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  border-color: var(--cycler-border);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    0 0 10px var(--cycler-button-glow);
}

.theme-toggle button:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1em;
  width: 95%;
  max-width: 600px;
  margin: 2em auto 1.5em auto;
  padding: 1.2em 1em;
  color: var(--panel-text);
  font-size: 0.9em;
  border: 1px solid var(--cycler-border);
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
  box-sizing: border-box;
}

footer p {
  margin: 0;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================ */

@media (max-width: 440px) {
  body {
    padding-bottom: 16px;
  }
  
  header {
    width: 95%;
  }

  .container {
    width: 95%;
    gap: 0.7em;
  }

  .panel {
    padding: 0.7em;
  }

  .game-grid {
    max-width: 280px;
    gap: 8px;
  }
  
  .scoreboard {
    gap: 0.5em;
  }
  
  .score-card {
    padding: 0.4em;
  }
  
  .score-value {
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
    background-position: 0% 50%;
  }
  .grid-cell span,
  .match-banner h2 {
    animation: none;
  }
}
