
:root {
  --ink: #13231e;
  --muted: #6f7c76;
  --cream: #f7f5ee;
  --paper: #fffefb;
  --green: #1f7456;
  --green-dark: #14513e;
  --mint: #dff2e8;
  --gold: #d9a73e;
  --line: #e5e6df;
  --tile: #ebece7;
  --shadow: 0 24px 60px rgba(20, 50, 40, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--cream);
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  position: relative;
  min-height: 100svh;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 24px 22px 40px;
  overflow: hidden;
}

.home-screen {
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.home-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    linear-gradient(rgba(31, 116, 86, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 116, 86, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 80% 8%, #edf8f1 0, transparent 34%),
    var(--cream);
  background-size: 38px 38px, 38px 38px, auto, auto;
}

.orb {
  position: absolute;
  z-index: -2;
  border-radius: 999px;
  filter: blur(1px);
  opacity: 0.68;
  pointer-events: none;
}

.orb-one {
  width: 180px;
  height: 180px;
  top: 110px;
  left: -110px;
  background: #d7ecdf;
}

.orb-two {
  width: 100px;
  height: 100px;
  top: 300px;
  right: -65px;
  border: 22px solid #f1dfb4;
}

.home-header,
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: rtl;
  white-space: nowrap;
}

.brand-tiles {
  display: flex;
  direction: rtl;
  gap: 3px;
}

.brand-tiles i {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.brand-tiles i:nth-child(2) {
  background: var(--gold);
}

.brand-name {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -1px;
}

.brand-dot {
  margin-right: -4px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 9px;
  font-weight: 800;
}

.hero {
  margin-top: 62px;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid #d7e7de;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.eyebrow span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #31aa78;
  box-shadow: 0 0 0 4px rgba(49, 170, 120, 0.12);
}

.hero h1 {
  margin: 18px 0 10px;
  font-size: clamp(42px, 11vw, 68px);
  line-height: 1.13;
  font-weight: 900;
  letter-spacing: -2.5px;
}

.hero h1 em {
  color: var(--green);
  font-style: normal;
}

.hero p {
  width: min(100%, 500px);
  margin: 0 auto;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
}

.entry-card {
  width: min(100%, 490px);
  margin: 34px auto 0;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  background: rgba(255, 254, 251, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.field-label,
.secret-card label,
.guess-form label {
  display: block;
  margin-bottom: 8px;
  color: #3e4a45;
  font-size: 13px;
  font-weight: 800;
}

.text-input,
.code-input,
.word-entry,
.guess-controls input {
  width: 100%;
  border: 1.5px solid var(--line);
  outline: 0;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.text-input:focus,
.code-input:focus,
.word-entry:focus-within,
.guess-controls input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 116, 86, 0.1);
}

.text-input {
  height: 54px;
  padding: 0 16px;
  border-radius: 15px;
}

.primary-button,
.secondary-button {
  min-height: 54px;
  border-radius: 15px;
  font-weight: 800;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  border: 0;
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 22px rgba(31, 116, 86, 0.22);
}

.primary-button b {
  font-size: 20px;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--green-dark);
}

.primary-button:disabled,
.secondary-button:disabled,
.start-button:disabled,
.guess-controls button:disabled {
  opacity: 0.42;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #929994;
  font-size: 11px;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 9px;
}

.code-input {
  height: 54px;
  padding: 0 13px;
  border-radius: 15px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
}

.secondary-button {
  border: 1.5px solid #cfd7d2;
  background: #f7f9f7;
  color: var(--green-dark);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--mint);
}

.alert {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.alert.error {
  border: 1px solid #f0cdca;
  background: #fff1ef;
  color: #9b352d;
}

.alert.success {
  border: 1px solid #c8e4d5;
  background: #edf9f2;
  color: var(--green-dark);
}

.how-it-works {
  display: flex;
  width: min(100%, 430px);
  align-items: center;
  justify-content: space-between;
  margin: 28px auto 0;
  padding: 0 4px;
}

.how-it-works div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.how-it-works div > span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: #e8eee9;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 900;
}

.how-it-works p {
  display: flex;
  flex-direction: column;
  margin: 0;
  line-height: 1.25;
}

.how-it-works b {
  font-size: 11px;
}

.how-it-works small {
  color: #89918d;
  font-size: 9px;
}

.how-it-works > i {
  width: 20px;
  height: 1px;
  background: #cfd5d1;
}

.room-screen {
  padding-bottom: 60px;
}

.room-screen::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 250px;
  background: linear-gradient(180deg, #e8f4ed 0%, transparent 100%);
}

.room-header {
  padding-bottom: 20px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #d7ded9;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: #5d6964;
  font-size: 25px;
  line-height: 1;
}

.room-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  border: 1px solid #d8e5dd;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 24px rgba(30, 72, 55, 0.05);
}

.room-code-bar div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code-bar small {
  color: var(--muted);
  font-size: 11px;
}

.room-code-bar strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: 2px;
}

.room-code-bar button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.lobby-panel,
.game-panel {
  width: min(100%, 580px);
  margin: 30px auto 0;
}

.section-heading {
  text-align: center;
}

.step-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e1f0e8;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 800;
}

.section-heading h1 {
  margin: 10px 0 4px;
  font-size: 27px;
  letter-spacing: -0.8px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

.player-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 13px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}

.player-card.active {
  border-color: #acd4c1;
  background: #f6fcf8;
}

.avatar,
.match-player > span {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 15px;
  font-weight: 900;
}

.player-card.active .avatar {
  background: var(--green);
  color: #fff;
}

.player-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.player-copy small,
.secret-saved small,
.waiting-host small,
.match-player small,
.match-clock small,
.exhausted-note small,
.reveal-words small {
  color: var(--muted);
  font-size: 9px;
}

.player-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready-state {
  padding: 4px 7px;
  border-radius: 999px;
  background: #f0f0ed;
  color: #858b87;
  font-size: 8px;
  font-weight: 800;
}

.ready-state.ready {
  background: #dff2e8;
  color: var(--green-dark);
}

.empty-player {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.4);
}

.empty-player .avatar {
  background: #eeefeb;
  color: #8b928e;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.5s ease infinite;
}

.secret-card {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid #e1e2dc;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 14px 38px rgba(34, 55, 47, 0.06);
}

.word-entry {
  display: flex;
  height: 55px;
  align-items: center;
  border-radius: 15px;
  overflow: hidden;
}

.word-entry input {
  min-width: 0;
  height: 100%;
  flex: 1;
  padding: 0 15px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.word-entry span {
  padding: 0 14px;
  color: #929a96;
  direction: ltr;
  font-size: 11px;
}

.secret-saved {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checkmark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.secret-saved > div {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.masked-word {
  color: var(--ink);
  direction: ltr;
  font-size: 23px;
  letter-spacing: 6px;
  line-height: 1;
}

.secret-saved > button {
  padding: 8px 11px;
  border: 0;
  border-radius: 10px;
  background: #edf2ef;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 800;
}

.change-secret {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.change-secret .secondary-button {
  min-height: 55px;
}

.start-zone {
  margin-top: 14px;
}

.start-button {
  display: flex;
  width: 100%;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 0;
  border-radius: 20px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 28px rgba(19, 35, 30, 0.18);
}

.play-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: var(--green);
  font-size: 13px;
  padding-right: 2px;
}

.start-button > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.start-button b {
  font-size: 15px;
}

.start-button small {
  color: #b9c0bd;
  font-size: 9px;
}

.waiting-host,
.exhausted-note {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px dashed #cfd9d3;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
}

.waiting-host p,
.exhausted-note p {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.waiting-host b,
.exhausted-note b {
  font-size: 12px;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.loader {
  width: 26px;
  height: 26px;
  border: 3px solid #cfe1d8;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader.small {
  width: 22px;
  height: 22px;
  border-width: 2px;
}

.match-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 15px;
  border: 1px solid #dde3df;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(26, 54, 43, 0.06);
}

.match-player {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.match-player.self {
  justify-content: flex-start;
}

.match-player > span {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 13px;
}

.match-player.self > span {
  background: var(--green);
  color: #fff;
}

.match-player p {
  display: flex;
  min-width: 0;
  flex-direction: column;
  margin: 0;
}

.match-player b {
  max-width: 90px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-clock {
  display: flex;
  min-width: 74px;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.match-clock strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: 1px;
}

.race-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  margin: 17px 3px;
  color: var(--muted);
  font-size: 9px;
}

.race-status b {
  color: var(--ink);
}

.race-track {
  height: 5px;
  border-radius: 99px;
  background: #dfe3df;
  overflow: hidden;
  direction: rtl;
}

.race-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--green));
  transition: width 0.3s ease;
}

.board {
  display: flex;
  width: min(100%, 380px);
  flex-direction: column;
  gap: 7px;
  margin: 0 auto;
}

.word-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.letter-tile {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1.5px solid #d8dbd7;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 900;
  line-height: 1;
}

.word-row.active .letter-tile {
  border-color: #b7c8bf;
  background: #fff;
}

.word-row.active .letter-tile.filled {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 116, 86, 0.07);
}

.letter-tile.correct {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  box-shadow: 0 5px 10px rgba(31, 116, 86, 0.18);
}

.letter-tile.present {
  border-color: var(--gold);
  background: var(--gold);
  color: #fff;
  box-shadow: 0 5px 10px rgba(217, 167, 62, 0.18);
}

.letter-tile.absent {
  border-color: #727a76;
  background: #727a76;
  color: #fff;
}

.guess-form {
  width: min(100%, 440px);
  margin: 19px auto 0;
}

.guess-controls {
  display: grid;
  grid-template-columns: 1fr 94px;
  gap: 8px;
}

.guess-controls input {
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 13px;
}

.guess-controls button {
  border: 0;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.exhausted-note {
  width: min(100%, 440px);
  margin: 19px auto 0;
}

.exhausted-note > span {
  font-size: 21px;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 17px;
  color: #7c8580;
  font-size: 8px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.legend i.correct {
  background: var(--green);
}

.legend i.present {
  background: var(--gold);
}

.legend i.absent {
  background: #727a76;
}

.result-card {
  width: min(100%, 460px);
  margin: 24px auto 0;
  padding: 25px;
  border: 1px solid #cfe5da;
  border-radius: 25px;
  background: linear-gradient(160deg, #effaf4, #fffefb 65%);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-card.lose {
  border-color: #e5dfd1;
  background: linear-gradient(160deg, #f5f1e8, #fffefb 65%);
}

.result-card.draw {
  border-color: #dddeda;
  background: var(--paper);
}

.result-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  margin: 0 auto 10px;
  border-radius: 17px;
  background: var(--green);
  color: #fff;
  font-size: 25px;
}

.result-card.lose .result-icon,
.result-card.draw .result-icon {
  background: #887b5e;
}

.result-kicker {
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.result-card h2 {
  margin: 5px 0 4px;
  font-size: 27px;
}

.result-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.reveal-words {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.reveal-words div {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.reveal-words strong {
  margin-top: 2px;
  font-size: 18px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  50% { opacity: 0.35; transform: scale(0.8); }
}

@media (min-width: 740px) {
  .app-shell {
    min-height: calc(100svh - 40px);
    margin-block: 20px;
    border: 1px solid rgba(215, 220, 216, 0.7);
    border-radius: 30px;
    box-shadow: 0 22px 70px rgba(20, 45, 36, 0.09);
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 16px;
  }

  .hero {
    margin-top: 52px;
  }

  .hero h1 {
    font-size: 44px;
  }

  .entry-card {
    padding: 18px;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }

  .player-card {
    min-height: 66px;
  }

  .letter-tile {
    border-radius: 11px;
  }

  .match-player p {
    display: none;
  }

  .match-player {
    justify-content: center;
  }

  .match-player.self {
    justify-content: center;
  }
}

@media (max-width: 390px) {
  .brand-dot {
    display: none;
  }

  .join-form {
    grid-template-columns: 1fr 112px;
  }

  .how-it-works > i {
    width: 10px;
  }

  .how-it-works small {
    display: none;
  }

  .legend {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
