* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Courier New", "Lucida Console", monospace;
  background: #f7d44a;
  color: #2d2104;
  image-rendering: pixelated;
  overflow-x: hidden;
}

body.game-active {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.container {
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 16px;
}

/* In-game: hide lobby header and fit table in viewport (no extra scroll) */
body.game-active main.container {
  margin: 0;
  padding: 4px 10px;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.game-active .site-header {
  display: none;
}

body.game-active .card#startedView {
  margin: 0;
  padding: 6px 10px;
  box-shadow: 4px 4px 0 #9f7716;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.game-active .table-arena {
  height: 100%;
  max-height: none;
  min-height: 210px;
  margin-top: 0;
  margin-bottom: 0;
}

body.game-active .word-submit--top {
  margin-bottom: 2px;
  padding-bottom: 2px;
}

body.game-active .actions {
  margin-top: 4px;
}

body.game-active .flipped-tiles {
  flex: 0 0 auto;
  min-height: 40px;
  max-height: 108px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  padding-bottom: 4px;
  border-bottom-width: 1px;
  justify-content: flex-start;
  gap: 4px;
}

h1,
h2,
h3 {
  margin-top: 0;
}

.site-header {
  text-align: center;
  margin-bottom: 8px;
}

.site-title {
  margin: 0 0 12px;
  padding: 0;
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
}

.site-title-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  justify-content: center;
  align-items: center;
}

.title-letter-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  aspect-ratio: 1 / 1;
  padding: 0;
  font-size: clamp(1.5rem, 5.5vw, 2.65rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background: url("/assets/tile.png") center / 100% 100% no-repeat;
  color: #2c2418;
  box-shadow: none;
  transition:
    transform 180ms ease,
    filter 180ms ease;
  will-change: transform;
}

.title-letter-tile:hover {
  transform: rotate(-6deg) translateY(-1px);
  filter: brightness(1.04);
}

.title-letter-tile:nth-child(even):hover {
  transform: rotate(6deg) translateY(-1px);
}

.subtitle {
  opacity: 0.9;
}

.card {
  background: #ffe88a;
  border: 3px solid #6b4f10;
  border-radius: 0;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 6px 6px 0 #9f7716;
}

#startedView {
  background: #ffe88a;
}

.your-turn-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -4px 0 10px;
  padding: 8px 12px;
  border: 3px solid;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-height: 44px;
  box-sizing: border-box;
}

.your-turn-bar--active {
  background: #1a5c1a;
  color: #cfff8f;
  border-color: #0d3d0d;
}

.your-turn-bar--active .your-turn-icon {
  background: #3d9a3d;
  border-color: #0f4d0f;
  box-shadow: 0 0 0 2px #1a1a0a;
}

.your-turn-bar--active .turn-timer {
  color: #ffffaa;
}

.your-turn-bar--idle {
  background: #4d4a42;
  color: #ece8df;
  border-color: #2c2924;
}

.your-turn-bar--idle .your-turn-icon {
  background: #6b6560;
  border-color: #3a3632;
  box-shadow: 0 0 0 2px #252220;
}

.your-turn-bar--idle .turn-timer {
  color: #d8d4cc;
}

.your-turn-bar--ended {
  background: #3a4550;
  color: #d8e2ec;
  border-color: #232a32;
}

.your-turn-bar--ended .your-turn-icon {
  background: #5a6a78;
  border-color: #343d46;
  box-shadow: 0 0 0 2px #1a1f24;
}

.your-turn-bar--ended .turn-timer {
  color: #c5d0da;
}

.your-turn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid;
  border-radius: 0;
}

.your-turn-label {
  min-width: 0;
  text-align: center;
}

.turn-timer {
  font-variant-numeric: tabular-nums;
  min-width: 2.5ch;
  font-size: 1.1em;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: #4b360a;
}

input {
  width: 100%;
  background: #fff4be;
  border: 3px solid #7a5b10;
  border-radius: 0;
  color: #2a1f07;
  padding: 10px;
  margin-bottom: 12px;
  font-family: inherit;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions--started {
  margin-top: 10px;
}

.help-icon-btn {
  min-width: 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

.sound-toggle-btn {
  min-width: 88px;
  padding: 8px 10px;
}

.status-slot {
  min-height: 1.25em;
  margin-top: 8px;
}

.status-slot--game {
  margin-top: 0;
  margin-bottom: 0;
  height: 5.3em;
  min-height: 5.3em;
  max-height: 5.3em;
  overflow: hidden;
}

.status-slot .status {
  margin: 0;
}

button {
  border: 3px solid #5f460f;
  border-radius: 0;
  background: #ffd24a;
  color: #2b1f05;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 3px 3px 0 #8c6711;
  font-family: inherit;
  text-transform: uppercase;
}

button.secondary {
  background: #f7be2f;
}

button:hover {
  filter: brightness(1.02);
}

.join-group {
  margin-top: 12px;
  border-top: 2px dashed #8e6b15;
  padding-top: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.room-code {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #4a3308;
}

.room-code strong {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px 4px;
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 1;
  letter-spacing: 0.08em;
  color: #2b1f05;
  background: #ffe9a5;
  border: 3px solid #6b4f10;
  box-shadow: 3px 3px 0 #9f7716;
}

#playersList {
  margin: 0;
  padding-left: 18px;
}

#playersList li {
  margin-bottom: 6px;
}

.waiting-player-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.waiting-player-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.host-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f7cf4f;
  background: rgba(48, 32, 12, 0.75);
  border: 1px solid #3a2a0d;
  padding: 1px 3px;
  font-size: 1.05em;
  font-weight: 700;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.55),
    0 0 2px rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 213, 92, 0.2);
}

.avatar-customizer {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border: 2px solid #6b4f10;
  background: rgba(255, 255, 255, 0.42);
  width: 100%;
}

.avatar-customizer-title {
  margin: 0 0 8px;
}

.avatar-customizer-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 10px;
  min-height: 74px;
}

.avatar-customizer-stage {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 6px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.avatar-customizer-stage .avatar-customizer-preview {
  margin: 0;
  min-height: 150px;
}

.avatar-customizer-actions {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.avatar-arrow {
  position: static;
  width: 30px;
  height: 30px;
  padding: 0;
  border-width: 2px;
  box-shadow: 2px 2px 0 #8c6711;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
}

.avatar-control-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 190px;
}

.avatar-control-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.avatar-control-label {
  min-width: 84px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #3b2a09;
}
.avatar-arrow--facial-left,
.avatar-arrow--facial-right,
.avatar-arrow--item-left,
.avatar-arrow--item-right {
  display: none;
}

.host-flip-options {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid #6b4f10;
  border-radius: 0;
}

.host-flip-options-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #3d2b08;
  text-transform: none;
  letter-spacing: 0.02em;
}

.host-flip-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.host-flip-seconds-label {
  display: inline;
  margin: 0;
  font-size: 0.8rem;
  color: #3d2b08;
}

#flipTurnSecondsInput {
  width: 5.5rem;
  max-width: 100%;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff4e8;
  border: 2px solid #6b4f10;
  color: #2a1f07;
  border-radius: 0;
}

#flipTurnSecondsInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.host-flip-nolimit-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.8rem;
  color: #3d2b08;
  font-weight: 600;
  cursor: pointer;
}

.host-flip-nolimit-label input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.flip-turn-readout {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: #3d2b08;
  opacity: 0.9;
  text-align: left;
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.tiles {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
}

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 0;
  border: none;
  background: url("/assets/tile.png") center / 100% 100% no-repeat;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #2c2418;
  font-size: 0.95rem;
  box-shadow: none;
}

/* Revealed letters in the top row: match middle pile scale (not smaller than face-down) */
.table-center .flipped-tiles .tile,
.table-center .flipped-tiles button.tile {
  width: clamp(30px, 5.5vmin, 46px);
  height: clamp(30px, 5.5vmin, 46px);
  min-width: 28px;
  min-height: 28px;
  flex: 0 0 auto;
  aspect-ratio: 1;
  font-size: clamp(0.96rem, 3.5vmin, 1.42rem);
  box-sizing: border-box;
}

button.tile {
  cursor: pointer;
}

.tile.down {
  background: linear-gradient(145deg, #d8b35e, #b98d37);
  border-color: #8a661b;
}

.tile.used {
  background: #6e5d47;
  border-color: #584731;
  opacity: 0.5;
}

button.tile:disabled {
  cursor: not-allowed;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.game-board-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(0, 2fr) minmax(170px, 1fr);
  gap: 10px;
}

.game-center-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.game-center-column .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.table-arena {
  position: relative;
  margin: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
}

.wood-table {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
  padding: 8px;
  min-height: 0;
  background:
    linear-gradient(90deg, rgba(68, 39, 19, 0.35), rgba(163, 104, 58, 0.28), rgba(68, 39, 19, 0.35)),
    repeating-linear-gradient(
      0deg,
      #8a5a2f 0px,
      #8a5a2f 10px,
      #9a6637 10px,
      #9a6637 20px
    );
  border: 10px solid #4b2f19;
  box-shadow:
    inset 0 0 0 2px #c0884f,
    0 16px 28px rgba(0, 0, 0, 0.32);
}

.seats-rail {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 10px;
  padding: 6px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(40, 24, 10, 0.35);
  background: rgba(0, 0, 0, 0.12);
}

.seat {
  position: relative;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.seats-rail .avatar {
  width: 82px;
  height: 82px;
}

.seats-rail .avatar.avatar--pixel {
  background: #f4e5b6;
}

.seats-rail .seat-label {
  font-size: 0.96rem;
}

.seats-rail .seat-bank {
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
  padding: 6px;
}

.seats-rail .bank-tile {
  width: clamp(22px, 4.8vmin, 32px);
  height: clamp(22px, 4.8vmin, 32px);
  font-size: clamp(0.55rem, 2vmin, 0.78rem);
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 0;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: #ffe9a5;
  border: 3px solid #6f5214;
}

.avatar--pixel {
  position: relative;
  overflow: hidden;
  image-rendering: pixelated;
  background: transparent;
}

.avatar--pixel.avatar--special-accessory {
  overflow: visible;
}

.avatar-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.avatar-layer--special-accessory {
  inset: auto;
  left: 50%;
  top: 50%;
  width: auto;
  height: auto;
  max-width: 112%;
  max-height: 112%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  image-rendering: auto;
  z-index: 6;
}

.avatar--mini {
  width: 30px !important;
  height: 24px !important;
  border-width: 2px;
}

.avatar--wait {
  width: 86px !important;
  height: 86px !important;
  border-width: 2px;
}

.avatar--preview {
  width: 132px !important;
  height: 132px !important;
  border-width: 3px;
}

.waiting-layout {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.2fr);
  gap: 16px;
  align-items: start;
  margin-top: 8px;
}

.waiting-layout-col {
  min-width: 0;
}

.waiting-layout-col--players {
  border: 2px solid rgba(107, 79, 16, 0.45);
  background: rgba(255, 255, 255, 0.28);
  padding: 10px 12px;
}

.waiting-layout-col--players h3 {
  margin: 0 0 8px;
}

.waiting-layout-col--players #playersList {
  margin: 0;
}

@media (max-width: 820px) {
  .waiting-layout {
    grid-template-columns: 1fr;
  }

  .avatar-customizer-stage {
    flex-direction: column;
  }

  .avatar-control-list {
    min-width: 0;
    width: 100%;
    max-width: 280px;
  }
}

.avatar--pixel .avatar-head,
.avatar--pixel .avatar-hair,
.avatar--pixel .avatar-eyes,
.avatar--pixel .avatar-eyewear,
.avatar--pixel .avatar-mouth,
.avatar--pixel .avatar-facial,
.avatar--pixel .avatar-torso,
.avatar--pixel .avatar-item {
  position: absolute;
  display: block;
}

.avatar--pixel .avatar-head {
  left: 18%;
  top: 10%;
  width: 64%;
  height: 50%;
  --skin-base: #d9a97e;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0 14%, transparent 14% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0 7%, transparent 7% 93%, rgba(0, 0, 0, 0.12) 93% 100%),
    var(--skin-base);
}

.avatar--pixel[data-skin="light"] .avatar-head {
  --skin-base: #f2cfae;
}
.avatar--pixel[data-skin="tan"] .avatar-head {
  --skin-base: #d9a97e;
}
.avatar--pixel[data-skin="brown"] .avatar-head {
  --skin-base: #a7744f;
}
.avatar--pixel[data-skin="dark"] .avatar-head {
  --skin-base: #6f4b34;
}
.avatar--pixel[data-skin="purple"] .avatar-head {
  --skin-base: #8f76c7;
}
.avatar--pixel[data-skin="green"] .avatar-head {
  --skin-base: #76b087;
}
.avatar--pixel[data-skin="blue"] .avatar-head {
  --skin-base: #6f98cc;
}

.avatar--pixel .avatar-hair {
  left: 14%;
  top: 2%;
  width: 72%;
  height: 18%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0 22%, rgba(0, 0, 0, 0.14) 22% 100%), #3e2a1a;
  opacity: 0;
}

.avatar--pixel[data-hair="short"] .avatar-hair {
  opacity: 1;
  top: 4%;
  left: 16%;
  width: 68%;
  height: 18%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0 22%, rgba(0, 0, 0, 0.1) 22% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0 10%, transparent 10% 90%, rgba(0, 0, 0, 0.12) 90% 100%),
    #3e2a1a;
}
.avatar--pixel[data-hair="long"] .avatar-hair {
  opacity: 1;
  left: 12%;
  width: 76%;
  height: 26%;
  top: 1%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0 18%, transparent 18% 100%),
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.12) 0 10%,
      transparent 10% 18%,
      rgba(0, 0, 0, 0.14) 18% 24%,
      transparent 24% 76%,
      rgba(0, 0, 0, 0.14) 76% 82%,
      transparent 82% 90%,
      rgba(0, 0, 0, 0.12) 90% 100%
    ),
    #4c3320;
  box-shadow:
    0 14px 0 -8px #4c3320,
    0 18px 0 -10px #3a2618;
}
.avatar--pixel[data-hair="cap"] .avatar-hair {
  opacity: 1;
  left: 10%;
  top: 3%;
  width: 80%;
  height: 20%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0 30%, transparent 30% 100%),
    linear-gradient(90deg, transparent 0 18%, rgba(0, 0, 0, 0.16) 18% 82%, transparent 82% 100%),
    #b5332e;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.26),
    0 3px 0 #7e1f1b,
    0 6px 0 -4px #5d1512;
}
.avatar--pixel[data-hair="beanie"] .avatar-hair {
  opacity: 1;
  left: 12%;
  width: 76%;
  top: 1%;
  height: 23%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0 20%, rgba(0, 0, 0, 0.12) 20% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0 8%, transparent 8% 92%, rgba(0, 0, 0, 0.12) 92% 100%),
    #2f4b79;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 -3px 0 #5b7bb0,
    0 5px 0 -3px #22395f;
}

.avatar--pixel .avatar-eyes {
  left: 28%;
  top: 28%;
  width: 44%;
  height: 9%;
  background:
    linear-gradient(
      to right,
      transparent 0 10%,
      #3b2a1a 10% 12%,
      #1f140a 12% 22%,
      transparent 22% 78%,
      #1f140a 78% 88%,
      #3b2a1a 88% 90%,
      transparent 88% 100%
    );
}

.avatar--pixel[data-expression="wink"] .avatar-eyes {
  background:
    linear-gradient(
      to right,
      transparent 0 10%,
      #1f140a 10% 20%,
      transparent 20% 58%,
      #1f140a 58% 100%
    );
}

.avatar--pixel .avatar-eyewear {
  left: 20%;
  top: 26%;
  width: 60%;
  height: 11%;
  opacity: 0;
  border: 2px solid #4a3f34;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26) 0 30%, rgba(255, 255, 255, 0.08) 30% 100%),
    rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.avatar--pixel[data-eyewear="glasses"] .avatar-eyewear {
  opacity: 1;
}
.avatar--pixel[data-eyewear="shades"] .avatar-eyewear {
  opacity: 1;
  border-color: #111;
  background: #2b2b2b;
}
.avatar--pixel[data-eyewear="monocle"] .avatar-eyewear {
  opacity: 1;
  left: 24%;
  width: 20%;
  border-color: #7a5d21;
  background: rgba(255, 232, 160, 0.2);
}

.avatar--pixel .avatar-mouth {
  left: 40%;
  top: 44%;
  width: 20%;
  height: 4%;
  background: #5e2f2f;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 -1px 0 rgba(0, 0, 0, 0.16) inset;
}

.avatar--pixel[data-expression="smile"] .avatar-mouth {
  top: 43%;
  left: 36%;
  width: 28%;
  height: 10%;
  border-bottom: 3px solid #5e2f2f;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  border-radius: 0 0 10px 10px;
  background: transparent;
  box-shadow: none;
}

.avatar--pixel[data-expression="frown"] .avatar-mouth {
  top: 45%;
  left: 36%;
  width: 28%;
  height: 8%;
  border-top: 3px solid #5e2f2f;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  box-shadow: none;
}

.avatar--pixel[data-expression="surprised"] .avatar-mouth {
  top: 42%;
  left: 43%;
  width: 14%;
  height: 14%;
  border-radius: 50%;
  background: #5e2f2f;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}

.avatar--pixel[data-expression="wink"] .avatar-mouth {
  top: 44%;
  left: 38%;
  width: 24%;
  height: 5%;
  background: linear-gradient(90deg, transparent 0 8%, #5e2f2f 8% 92%, transparent 92% 100%);
}

.avatar--pixel[data-expression="laugh"] .avatar-mouth {
  top: 43%;
  left: 35%;
  width: 30%;
  height: 12%;
  border-radius: 0 0 10px 10px;
  background:
    linear-gradient(180deg, #4d1f1f 0 65%, #d9a7a7 65% 75%, #4d1f1f 75% 100%);
  box-shadow: none;
}

.avatar--pixel[data-expression="angry"] .avatar-mouth {
  top: 44%;
  left: 36%;
  width: 28%;
  height: 6%;
  background:
    linear-gradient(90deg, transparent 0 8%, #5e2f2f 8% 92%, transparent 92% 100%);
  box-shadow: none;
}

.avatar--pixel[data-expression="sad"] .avatar-mouth {
  top: 47%;
  left: 37%;
  width: 26%;
  height: 8%;
  border-top: 3px solid #5e2f2f;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  box-shadow: none;
}

.avatar--pixel .avatar-facial {
  left: 30%;
  top: 46%;
  width: 40%;
  height: 10%;
  opacity: 0;
  background: #3b2b1d;
  box-shadow: none;
}

.avatar--pixel[data-facial-color="dark"] .avatar-facial { background: #3b2b1d; }
.avatar--pixel[data-facial-color="black"] .avatar-facial { background: #1f1f1f; }
.avatar--pixel[data-facial-color="brown"] .avatar-facial { background: #5b3a22; }
.avatar--pixel[data-facial-color="blonde"] .avatar-facial { background: #b59042; }
.avatar--pixel[data-facial-color="red"] .avatar-facial { background: #8f3b2f; }
.avatar--pixel[data-facial-color="gray"] .avatar-facial { background: #7a7a7a; }

.avatar--pixel[data-facial-hair="mustache"] .avatar-facial {
  opacity: 1;
  top: 42%;
  left: 29%;
  width: 42%;
  height: 6%;
  border-radius: 0;
  background:
    linear-gradient(
      90deg,
      transparent 0 8%,
      #3b2b1d 8% 40%,
      transparent 40% 60%,
      #3b2b1d 60% 92%,
      transparent 92% 100%
    );
}
.avatar--pixel[data-facial-hair="goatee"] .avatar-facial {
  opacity: 1;
  top: 48%;
  left: 41%;
  width: 18%;
  height: 11%;
  border-radius: 0;
  background:
    linear-gradient(
      180deg,
      #3b2b1d 0 70%,
      transparent 70% 100%
    ),
    linear-gradient(
      90deg,
      transparent 0 10%,
      #3b2b1d 10% 90%,
      transparent 90% 100%
    );
}
.avatar--pixel[data-facial-hair="beard"] .avatar-facial {
  opacity: 1;
  top: 42%;
  left: 20%;
  width: 60%;
  height: 18%;
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0 20%, transparent 20% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0 10%, transparent 10% 90%, rgba(0, 0, 0, 0.12) 90% 100%),
    #3b2b1d;
}

.avatar--pixel .avatar-torso {
  left: 10%;
  bottom: 0;
  width: 80%;
  height: 34%;
  --shirt-base: #4f7b57;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0 20%, transparent 20% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0 14%, transparent 14% 86%, rgba(0, 0, 0, 0.16) 86% 100%),
    var(--shirt-base);
}

.avatar--pixel .avatar-item {
  right: -8%;
  bottom: 6%;
  width: 14%;
  height: 54%;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 22%, transparent 22% 78%, rgba(0, 0, 0, 0.2) 78% 100%),
    #6f5a3a;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.16);
}

.avatar--pixel .avatar-item::before,
.avatar--pixel .avatar-item::after {
  content: "";
  position: absolute;
  display: block;
}

.avatar--pixel[data-held-item="trident"] .avatar-item {
  opacity: 1;
  width: 14%;
  right: -9%;
  background:
    linear-gradient(180deg, transparent 0 22%, #6f5a3a 22% 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 20%, transparent 20% 80%, rgba(0, 0, 0, 0.18) 80% 100%),
    #6f5a3a;
}

.avatar--pixel[data-held-item="trident"] .avatar-item::before {
  left: -45%;
  top: -12%;
  width: 190%;
  height: 24%;
  background:
    linear-gradient(
      90deg,
      transparent 0 9%,
      #cdbb79 9% 17%,
      transparent 17% 30%,
      #d8c98c 30% 38%,
      transparent 38% 62%,
      #d8c98c 62% 70%,
      transparent 70% 83%,
      #cdbb79 83% 91%,
      transparent 91% 100%
    );
}

.avatar--pixel[data-held-item="trident"] .avatar-item::after {
  left: -18%;
  top: 6%;
  width: 136%;
  height: 12%;
  background:
    linear-gradient(
      90deg,
      transparent 0 20%,
      #c5b06f 20% 80%,
      transparent 80% 100%
    );
}

.avatar--pixel[data-held-item="staff"] .avatar-item {
  opacity: 1;
  width: 13%;
  right: -9%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 25%, transparent 25% 80%, rgba(0, 0, 0, 0.22) 80% 100%),
    #5b4728;
}

.avatar--pixel[data-held-item="staff"] .avatar-item::before {
  left: -70%;
  top: -18%;
  width: 240%;
  height: 36%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 45% 45%, #b8f1ff 0 24%, #6ec6f2 24% 48%, rgba(76, 132, 187, 0.86) 48% 72%, transparent 72% 100%);
  box-shadow:
    0 0 0 2px rgba(91, 131, 179, 0.34),
    0 0 6px rgba(126, 210, 255, 0.45);
}

.avatar--pixel[data-held-item="staff"] .avatar-item::after {
  left: -20%;
  top: 8%;
  width: 140%;
  height: 10%;
  background:
    linear-gradient(90deg, transparent 0 14%, #7a5f39 14% 86%, transparent 86% 100%);
}

.avatar--pixel[data-held-item="shovel"] .avatar-item {
  opacity: 1;
  width: 13%;
  right: -9%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 0 22%, transparent 22% 78%, rgba(0, 0, 0, 0.2) 78% 100%),
    #5b4728;
}

.avatar--pixel[data-held-item="shovel"] .avatar-item::before {
  left: -58%;
  top: 66%;
  width: 218%;
  height: 34%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26) 0 20%, rgba(0, 0, 0, 0.16) 20% 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 0 12%, transparent 12% 88%, rgba(0, 0, 0, 0.16) 88% 100%),
    #9aa4ad;
  border-radius: 0 0 8px 8px;
}

.avatar--pixel[data-held-item="shovel"] .avatar-item::after {
  left: -24%;
  top: 8%;
  width: 148%;
  height: 10%;
  background:
    linear-gradient(90deg, transparent 0 12%, #7b6138 12% 88%, transparent 88% 100%);
}

.avatar--pixel[data-held-item="spear"] .avatar-item {
  opacity: 1;
  width: 12%;
  right: -8%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 22%, transparent 22% 78%, rgba(0, 0, 0, 0.2) 78% 100%),
    #6f5a3a;
}

.avatar--pixel[data-held-item="spear"] .avatar-item::before {
  left: -42%;
  top: -18%;
  width: 184%;
  height: 28%;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0 24%, rgba(0, 0, 0, 0.18) 24% 100%),
    #c7cbd1;
}

.avatar--pixel[data-held-item="spear"] .avatar-item::after {
  left: -16%;
  top: 10%;
  width: 132%;
  height: 9%;
  background:
    linear-gradient(90deg, transparent 0 18%, #8a6c40 18% 82%, transparent 82% 100%);
}

.avatar--pixel[data-shirt="green"] .avatar-torso { --shirt-base: #4f7b57; }
.avatar--pixel[data-shirt="blue"] .avatar-torso { --shirt-base: #3f6296; }
.avatar--pixel[data-shirt="red"] .avatar-torso { --shirt-base: #9c3b3b; }
.avatar--pixel[data-shirt="purple"] .avatar-torso { --shirt-base: #6f4a9b; }
.avatar--pixel[data-shirt="black"] .avatar-torso { --shirt-base: #2a2a2a; }
.avatar--pixel[data-shirt="white"] .avatar-torso { --shirt-base: #ece8df; }

.seat-label {
  font-size: 0.95rem;
  color: #ffe6a7;
  white-space: normal;
  font-weight: 700;
  text-align: left;
  text-shadow:
    0 1px 0 rgba(35, 20, 8, 0.9),
    0 0 2px rgba(25, 14, 6, 0.45);
}

.seat-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.seat-header .avatar {
  margin: 0;
  flex: 0 0 auto;
}

.seat-header .seat-label {
  margin: 0;
  line-height: 1.2;
}

.seat-score-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.seat-score {
  color: #fff2c9;
}

.seat-score-gain {
  color: #9dff97;
  font-weight: 700;
  animation: seat-score-gain-fade 1000ms ease-out forwards;
}

.seat-score-loss {
  color: #ff8f8f;
  font-weight: 700;
  animation: seat-score-gain-fade 1000ms ease-out forwards;
}

@keyframes seat-score-gain-fade {
  0% {
    opacity: 0;
    transform: translateY(3px);
  }
  14% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.middle-tiles-scaler {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.middle-tiles-scaler .middle-panel {
  position: relative;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  max-width: 100%;
  max-height: 100%;
  flex-shrink: 0;
}

.middle-tiles-scaler .middle-panel.middle-panel--up-pile {
  width: 100%;
  height: 100%;
}

.middle-tiles-scaler .tiles {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  gap: 2px;
  box-sizing: border-box;
}

.middle-tiles-scaler .tiles.tiles--up-pile {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
}

.middle-tiles-scaler .tiles.tiles--up-pile .tile,
.middle-tiles-scaler .tiles.tiles--up-pile button.tile {
  width: clamp(36px, 5.4vmin, 58px);
  height: clamp(36px, 5.4vmin, 58px);
  min-width: 32px;
  min-height: 32px;
  flex: 0 0 auto;
  aspect-ratio: 1;
  font-size: clamp(1.18rem, 4.1vmin, 1.78rem);
  transform: rotate(var(--tile-tilt, 0deg));
  transform-origin: center;
}

.middle-tiles-scaler .tiles.log-hidden {
  visibility: hidden;
  pointer-events: none;
}

.middle-tiles-scaler .game-event-log {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(52, 38, 22, 0.97) 0%, rgba(38, 26, 14, 0.98) 100%);
  border: 2px solid #6b4f10;
  font-size: clamp(0.78rem, min(2.25cqw, 2.25cqh), 0.98rem);
  line-height: 1.45;
  text-align: left;
}

.middle-tiles-scaler .game-event-log.hidden {
  display: none;
}

.game-log-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 10px;
  -webkit-overflow-scrolling: touch;
}

.game-log-chat-row {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: stretch;
  padding: 6px 8px;
  border-top: 2px solid rgba(107, 79, 16, 0.65);
  background: rgba(0, 0, 0, 0.22);
  margin-top: 6px;
  border: 2px solid rgba(107, 79, 16, 0.65);
}

.game-log-chat-row input {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 6px 8px;
  font-size: inherit;
  font-family: inherit;
  background: #fff4e8;
  border: 2px solid #6b4f10;
  color: #2a1f07;
  border-radius: 0;
}

.game-log-chat-row button {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 0.85em;
  text-transform: uppercase;
}

.seat-chat-bubbles {
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
  width: min(92%, 220px);
  pointer-events: none;
  z-index: 2;
}

.seat-chat-bubble {
  max-width: 100%;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.95);
  color: #2d2104;
  border: 2px solid #6b4f10;
  border-radius: 0;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
  opacity: 1;
  animation-name: seat-chat-bubble-fade;
  animation-duration: 4500ms;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-delay: calc(-1 * var(--bubble-age-ms, 0ms));
}

@keyframes seat-chat-bubble-fade {
  0%,
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.game-event-log .log-line {
  margin: 0 0 0.45em;
  padding: 0;
  border: none;
}

.game-event-log .log-line--event {
  color: #ffe066;
}

.game-event-log .log-line--event.log-line--steal-by-self {
  color: #88f16c;
}

.game-event-log .log-line--event.log-line--steal-against-self {
  color: #ff7f7f;
}

.game-event-log .log-line--event.log-line--muted {
  color: #e8c85a;
  opacity: 0.92;
  font-style: italic;
}

.game-event-log .log-line--chat {
  color: #ffffff;
}

.game-event-log .log-line--chat .log-chat-name {
  font-weight: 700;
  color: #ffffff;
}

.log-letter-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.28em;
  height: 1.28em;
  aspect-ratio: 1 / 1;
  margin: 0 0.04em;
  padding: 0;
  font-weight: 700;
  font-size: 0.92em;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background: url("/assets/tile.png") center / 100% 100% no-repeat;
  color: #2c2418;
  box-shadow: none;
}

.middle-tiles-scaler .tiles .tile,
.middle-tiles-scaler .tiles button.tile {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  max-width: none;
  max-height: none;
  font-size: clamp(0.35rem, min(2.2cqw, 2.2cqh), 0.7rem);
  padding: 0;
  line-height: 1;
  box-sizing: border-box;
}

.table-center {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  max-width: none;
  width: auto;
  height: 100%;
  max-height: 100%;
  background: rgba(35, 21, 10, 0.28);
  border: 1px solid rgba(255, 230, 200, 0.16);
  border-radius: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  height: 100%;
}

.table-flip-btn {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  z-index: 3;
  min-width: 78px;
  padding: 6px 10px;
}

.table-flip-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.flipped-tiles {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding-top: 34px;
  padding-bottom: 6px;
  border-bottom: 2px dashed rgba(95, 70, 15, 0.4);
}

.word-submit {
  margin-top: 12px;
}

.word-submit--top {
  margin-top: 0;
  margin-bottom: 3px;
  padding-bottom: 3px;
  border-bottom: none;
}

.word-submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.word-submit-row input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.seat-bank {
  margin-top: 6px;
  padding: 6px;
  border-radius: 0;
  background: rgba(255, 248, 214, 0.9);
  border: 2px solid #8b6a1f;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 6px 26px;
}

.seat-bank-empty {
  font-size: 0.72rem;
  opacity: 0.75;
}

.bank-word-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  max-width: 100%;
  overflow: visible;
  gap: 2px;
  margin-bottom: 0;
  flex: 0 0 auto;
  --row-tile-size: clamp(24px, 3vmin, 38px);
}

.bank-word-row .bank-tile {
  width: var(--row-tile-size);
  height: var(--row-tile-size);
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 0;
  border: none;
  background: url("/assets/tile.png") center / 100% 100% no-repeat;
  color: #2c2418;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.72rem, 2.4vmin, 1.12rem);
  font-weight: 700;
  box-sizing: border-box;
  line-height: 1;
  flex: 0 0 auto;
}

.game-start-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 14, 6, 0.78);
  backdrop-filter: blur(2px);
}

.game-start-overlay.hidden {
  display: none;
}

.game-start-overlay-count {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-tile {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(10rem, 30vmin, 16rem);
  height: clamp(10rem, 30vmin, 16rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: url("/assets/tile.png") center / 100% 100% no-repeat;
  color: #2c2418;
  font-size: clamp(4.4rem, 18vw, 10rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.muted {
  margin: 0;
  opacity: 0.75;
}

.status {
  min-height: 22px;
  opacity: 0.95;
}

.status.status--activity {
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.status .status-activity-line {
  margin: 0;
}

.status-activity-list {
  display: block;
  line-height: 1.15;
}

.status-activity-list .status-activity-line {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status.error {
  color: #8f1d1d;
}

.hidden {
  display: none;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(18, 12, 6, 0.68);
}

.help-modal.hidden {
  display: none;
}

.help-modal-card {
  width: min(680px, 96vw);
  max-height: min(86vh, 86dvh);
  overflow-y: auto;
  border: 3px solid #6b4f10;
  background: #ffe88a;
  box-shadow: 6px 6px 0 #9f7716;
  padding: 12px 14px;
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.help-modal-header h3 {
  margin: 0;
}

.help-modal-close {
  padding: 6px 8px;
}

.help-modal-subtitle {
  margin: 0 0 10px;
  color: #3a2908;
  font-size: 0.9rem;
}

.help-modal-list {
  margin: 6px 0 12px 20px;
  padding: 0;
}

.help-modal-list li {
  margin-bottom: 5px;
}
