/* ============================================================================
   Wordle clone — styling.
   Mirrors the look of the current NYT Wordle: same palette, tile/key sizing,
   and the pop / flip / shake / bounce animations.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* Evaluation palette (light theme) */
  --green: #6aaa64;
  --yellow: #c9b458;
  --absent-gray: #787c7e;

  /* High-contrast (color-blind) palette */
  --orange: #f5793a;
  --blue: #85c0f9;

  /* Active evaluation colors — swapped by the high-contrast toggle */
  --correct-color: var(--green);
  --present-color: var(--yellow);
  --absent-color: var(--absent-gray);

  /* Surfaces & text */
  --color-bg: #ffffff;
  --color-text: #1a1a1b;
  --color-tone-1: #1a1a1b;
  --color-tone-7: #ffffff;
  --header-border: #d3d6da;

  /* Tiles */
  --tile-border-empty: #d3d6da;
  --tile-border-filled: #878a8c;
  --tile-text-evaluated: #ffffff;

  /* Keyboard */
  --key-bg: #d3d6da;
  --key-text: #1a1a1b;
  --key-absent: #787c7e;
  --key-evaluated-text: #ffffff;

  /* Modals & toasts */
  --modal-bg: #ffffff;
  --overlay-bg: rgba(255, 255, 255, 0.5);
  --toast-bg: #121213;
  --toast-text: #ffffff;

  --header-height: 50px;
  --keyboard-height: 200px;
  font-family: "Helvetica Neue", Helvetica, Arial, "Clear Sans", sans-serif;
}

/* ---- Dark theme ---------------------------------------------------------- */
body.nightmode {
  --green: #538d4e;
  --yellow: #b59f3b;
  --absent-gray: #3a3a3c;

  --correct-color: var(--green);
  --present-color: var(--yellow);
  --absent-color: var(--absent-gray);

  --color-bg: #121213;
  --color-text: #d7dadc;
  --color-tone-1: #d7dadc;
  --color-tone-7: #121213;
  --header-border: #3a3a3c;

  --tile-border-empty: #3a3a3c;
  --tile-border-filled: #565758;

  --key-bg: #818384;
  --key-text: #d7dadc;
  --key-absent: #3a3a3c;

  --modal-bg: #121213;
  --overlay-bg: rgba(0, 0, 0, 0.5);
}

/* ---- High contrast (color-blind) — applies on top of light or dark ------- */
body.colorblind {
  --correct-color: var(--orange);
  --present-color: var(--blue);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============================================================================
   App shell
   ========================================================================== */
.App-module_game__yruqo {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---- Header -------------------------------------------------------------- */
.AppHeader-module_appHeader__Yck5N {
  height: var(--header-height);
  color: var(--color-tone-1);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.AppHeader-module_menuLeft__c1Bzg,
.AppHeader-module_menuRight__Gnmm {
  display: flex;
  align-items: center;
}

.AppHeader-module_menuLeft__c1Bzg {
  justify-content: flex-start;
  width: 100px;
}

.AppHeader-module_menuRight__Gnmm {
  justify-content: flex-end;
  width: 100px;
}

.AppHeader-module_wordmark__pXkBT {
  flex-grow: 1;
  text-align: center;
}

.AppHeader-module_title__Vg_lo {
  font-family: "Helvetica Neue", sans-serif;
  font-weight: 700;
  font-size: 36px;
  line-height: 100%;
  letter-spacing: 0.01em;
  margin: 0;
  pointer-events: none;
}

.ToolbarButton-module_button__7vmiV {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin: 0 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-tone-1);
}

.ToolbarButton-module_button__7vmiV svg {
  fill: var(--color-tone-1);
}

/* ============================================================================
   Board
   ========================================================================== */
.App-module_gameContainer__K_Cs6 {
  position: relative;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.Board-module_boardContainer__TBHNL {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.Board-module_board__jeoPS {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-gap: 5px;
  padding: 10px;
  box-sizing: border-box;
}

.Row-module_row__pwpBq {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-gap: 5px;
}

.Tile-module_tile__UWEHN {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  line-height: 2rem;
  font-weight: bold;
  vertical-align: middle;
  box-sizing: border-box;
  text-transform: uppercase;
  user-select: none;
  color: var(--color-text);
  aspect-ratio: 1 / 1;
}

.Tile-module_tile__UWEHN[data-state="empty"] {
  border: 2px solid var(--tile-border-empty);
}

.Tile-module_tile__UWEHN[data-state="tbd"] {
  background-color: var(--color-bg);
  border: 2px solid var(--tile-border-filled);
  color: var(--color-text);
}

.Tile-module_tile__UWEHN[data-state="correct"] {
  background-color: var(--correct-color);
  border: 2px solid var(--correct-color);
  color: var(--tile-text-evaluated);
}

.Tile-module_tile__UWEHN[data-state="present"] {
  background-color: var(--present-color);
  border: 2px solid var(--present-color);
  color: var(--tile-text-evaluated);
}

.Tile-module_tile__UWEHN[data-state="absent"] {
  background-color: var(--absent-color);
  border: 2px solid var(--absent-color);
  color: var(--tile-text-evaluated);
}

/* ---- Tile animations ----------------------------------------------------- */
.Tile-module_tile__UWEHN[data-animation="pop"] {
  animation-name: PopIn;
  animation-duration: 100ms;
}

@keyframes PopIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.Tile-module_tile__UWEHN[data-animation="flip-in"] {
  animation-name: FlipIn;
  animation-duration: 250ms;
  animation-timing-function: ease-in;
}

@keyframes FlipIn {
  0% {
    transform: rotateX(0);
  }
  100% {
    transform: rotateX(-90deg);
  }
}

.Tile-module_tile__UWEHN[data-animation="flip-out"] {
  animation-name: FlipOut;
  animation-duration: 250ms;
  animation-timing-function: ease-in;
}

@keyframes FlipOut {
  0% {
    transform: rotateX(-90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.Tile-module_tile__UWEHN[data-animation="win"] {
  animation-name: Bounce;
  animation-duration: 1000ms;
}

@keyframes Bounce {
  0%,
  20% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-30px);
  }
  50% {
    transform: translateY(5px);
  }
  60% {
    transform: translateY(-15px);
  }
  80% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(0);
  }
}

/* ---- Row shake (invalid guess) ------------------------------------------- */
.Row-module_row__pwpBq[data-animation="shake"] {
  animation-name: Shake;
  animation-duration: 600ms;
}

@keyframes Shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

/* ============================================================================
   Keyboard
   ========================================================================== */
.Keyboard-module_keyboard__uYuqf {
  height: var(--keyboard-height);
  margin: 0 8px;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.Keyboard-module_row__ilOKU {
  display: flex;
  width: 100%;
  margin: 0 auto 8px;
  touch-action: manipulation;
}

.Keyboard-module_half__rQfMo {
  flex: 0.5;
}

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

.Keyboard-module_row__ilOKU button:last-of-type {
  margin: 0;
}

.Key-module_oneAndAHalf__bq8Tw {
  flex: 1.5;
  font-size: 12px;
}

.Key-module_key__kchQI svg {
  width: 24px;
  height: 24px;
  fill: var(--key-text);
}

.Key-module_key__kchQI[data-state="correct"] {
  background-color: var(--correct-color);
  color: var(--key-evaluated-text);
}

.Key-module_key__kchQI[data-state="present"] {
  background-color: var(--present-color);
  color: var(--key-evaluated-text);
}

.Key-module_key__kchQI[data-state="absent"] {
  background-color: var(--key-absent);
  color: var(--key-evaluated-text);
}

.Key-module_key__kchQI[data-state="correct"] svg,
.Key-module_key__kchQI[data-state="present"] svg,
.Key-module_key__kchQI[data-state="absent"] svg {
  fill: var(--key-evaluated-text);
}

/* ============================================================================
   Toasts
   ========================================================================== */
.ToastContainer-module_toaster__G_LWb {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  width: fit-content;
}

#system-toaster {
  position: fixed;
  top: 70px;
}

.Toast-module_toast__iiVsN {
  position: relative;
  margin: 4px;
  background-color: var(--toast-bg);
  color: var(--toast-text);
  padding: 13px;
  border-radius: 4px;
  font-weight: 700;
  text-align: center;
  pointer-events: auto;
  animation: ToastFadeIn 100ms ease-in;
}

.Toast-module_toast__iiVsN.win {
  background-color: var(--correct-color);
  color: #ffffff;
}

.Toast-module_toast__iiVsN.fade {
  opacity: 0;
  transition: opacity 300ms ease-out;
}

@keyframes ToastFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================================================
   Modals
   ========================================================================== */
.Modal-module_overlay__nU_Lj {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: ToastFadeIn 100ms ease-in;
}

.Modal-module_modal__wsBfL {
  position: relative;
  background-color: var(--modal-bg);
  color: var(--color-text);
  border-radius: 8px;
  border: 1px solid var(--header-border);
  box-shadow: 0 4px 23px 0 rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  max-height: 90%;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.Modal-module_closeIcon__TcEKb {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
}

.Modal-module_closeIcon__TcEKb svg {
  fill: var(--color-tone-1);
}

.Modal-module_title__yScTH {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-align: center;
  text-transform: uppercase;
  margin: 8px 0 16px;
}

/* ---- Help modal ---------------------------------------------------------- */
.help-section {
  padding: 0 8px;
  font-size: 15px;
  line-height: 1.4;
}

.help-section h1 {
  font-size: 28px;
  margin: 8px 0;
}

.help-section .examples {
  border-top: 1px solid var(--header-border);
  border-bottom: 1px solid var(--header-border);
  margin: 16px 0;
  padding: 16px 0;
}

.help-example {
  margin-bottom: 16px;
}

.help-example .Row-module_row__pwpBq {
  display: grid;
  grid-template-columns: repeat(5, 40px);
  grid-gap: 4px;
  margin-bottom: 4px;
}

.help-example .Tile-module_tile__UWEHN {
  width: 40px;
  height: 40px;
  font-size: 1.6rem;
  aspect-ratio: auto;
}

/* ---- Stats modal --------------------------------------------------------- */
.statistics {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.statistic-container {
  flex: 1;
  text-align: center;
  max-width: 80px;
}

.statistic-container .statistic {
  font-size: 36px;
  font-weight: 400;
  line-height: 40px;
}

.statistic-container .label {
  font-size: 12px;
}

.guess-distribution {
  margin-bottom: 10px;
}

.distribution-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.graph-container {
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  padding-bottom: 4px;
  font-size: 14px;
  line-height: 20px;
}

.graph-container .guess {
  font-weight: bold;
  width: 16px;
}

.graph-container .graph {
  width: 100%;
  height: 100%;
  padding-left: 4px;
}

.graph-container .graph-bar {
  height: 100%;
  width: 0%;
  position: relative;
  background-color: var(--absent-color);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 8px;
  color: #ffffff;
  font-weight: bold;
  min-width: 20px;
}

.graph-container .graph-bar.highlight {
  background-color: var(--correct-color);
}

.stats-footer {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--header-border);
  padding-top: 16px;
  margin-top: 8px;
}

.countdown {
  flex: 1;
  text-align: center;
  border-right: 1px solid var(--header-border);
  padding-right: 8px;
}

.countdown .label {
  font-size: 12px;
}

.countdown .timer {
  font-size: 36px;
  font-weight: 400;
}

.share-area {
  flex: 1;
  text-align: center;
  padding-left: 8px;
}

.share-button,
.new-game-button {
  background-color: var(--correct-color);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  font-size: 18px;
  text-transform: uppercase;
  padding: 12px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px auto;
}

.new-game-button {
  background-color: var(--key-absent);
}

.share-button svg {
  fill: #ffffff;
}

/* ---- Settings modal ------------------------------------------------------ */
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--header-border);
}

.setting .text .title {
  font-size: 18px;
}

.setting .text .description {
  font-size: 12px;
  color: var(--absent-gray);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--absent-gray);
  transition: 0.3s;
  border-radius: 999px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--correct-color);
}

.switch input:checked + .slider::before {
  transform: translateX(12px);
}

/* ============================================================================
   Responsive
   ========================================================================== */
@media (max-height: 600px) {
  .Tile-module_tile__UWEHN {
    font-size: 1.5rem;
  }
}

@media (max-width: 360px) {
  .Key-module_key__kchQI {
    font-size: 11px;
  }
}
