.below {
  grid-template-columns: minmax(110px, .55fr) minmax(0, 3fr) minmax(260px, 1.25fr);
}

.below .me-panel { order: 1; }
.below .hand-panel { order: 2; }
.below .log-panel { order: 3; }

#pieceControls { display: none !important; }
#game .finish-label, #game .track-label { display: none !important; }
.rules-link { display: inline-block; padding: 12px 15px; text-decoration: none; font-weight: 750; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); }
.header-actions .rules-link[hidden] { display: none !important; }
.rules-link:hover { transform: translateY(-1px); }
.login-header { justify-content: center; text-align: center; }
.login-header #siteTitle .site-brand { font-size: clamp(28px, 5vw, 44px); }
.login-header .header-actions { display: none; }
.lobby-header > div:first-child { display: flex; flex-direction: column; align-items: flex-start; }
.lobby-header #siteTitle { order: 1; margin: 0 0 3px; font-size: clamp(16px, 2.1vw, 22px); }
.lobby-header #siteTitle .site-brand img { width: 1.94em; height: 1.94em; }
.lobby-header #siteSubtitle { order: 2; font-size: 17px; letter-spacing: .12em; }
.login { justify-content: flex-start; align-items: center; width: fit-content; max-width: 100%; min-height: 0; padding: 16px; }
.login:not([hidden]) { margin-inline: auto; }
.login form { margin-top: 0; }
.below .me-panel { padding: 20px; text-align: center; }
.below .me-panel h3 { text-align: center; }
#games { display: block; width: 100%; }
#games .lobby-group { min-width: 0; }
#games .lobby-group[hidden] { display: none !important; }
#games .lobby-group > h3 { margin: 4px 0 12px; font-family: Georgia, serif; font-size: 22px; }
#games .lobby-group > .games { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
#games .lobby-group > .games > .muted { grid-column: 1 / -1; }
#games .game-card { min-width: 0; padding: 16px; }
#games .lobby-group + .lobby-group { margin-top: 18px; }
#games .lobby-group .players { min-width: 0; max-width: 100%; }
.game-type-picker { margin: 0 0 20px; }
.game-color-chooser { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: #1d2a1dcc; }
.game-color-chooser[hidden] { display: none; }
.game-color-chooser-panel { width: min(500px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 18px 50px #0008; }
.game-color-chooser-panel h2 { margin: 0 0 6px; text-align: center; }
.game-color-chooser-panel>p { margin: 0 0 18px; color: var(--muted); text-align: center; }
.game-color-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.game-color-option { display: grid; justify-items: center; gap: 8px; padding: 12px 6px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); }
.game-color-option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--ink); }
.game-color-option:disabled { opacity: .38; cursor: not-allowed; }
.game-color-swatch { width: 42px; height: 42px; border: 3px solid #26332c; border-radius: 50%; background: var(--game-choice-color); box-shadow: inset 0 0 0 2px #ffffff80; }
.game-color-label { font-size: 12px; font-weight: 800; }
#gameColorChooserCancel { display: block; margin-left: auto; }
.game-type-filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.all-games-button { margin-bottom: 12px; padding: 8px 14px; border: 1px solid #aeb99e; border-radius: 999px; background: #fffdf7; color: var(--ink); font-size: 13px; font-weight: 750; }
.all-games-button[aria-pressed="true"] { border-color: var(--green); background: #e6f2d9; color: #42633e; }
.game-type-picker-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.game-type-picker-note { color: var(--muted); font-size: 12px; }
.game-type-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.game-type-card { position: relative; min-width: 0; }
.game-type-option { --game-card-start: #e6f2d9; --game-card-end: #f8f3d9; position: relative; display: flex; align-items: center; gap: 13px; width: 100%; min-width: 0; min-height: 90px; overflow: hidden; padding: 10px 52px 10px 10px; border: 0; border-radius: 20px; background: linear-gradient(120deg, var(--game-card-start), var(--game-card-end) 78%); color: var(--ink); font: inherit; text-align: left; cursor: pointer; box-shadow: none; transition: transform .16s ease, box-shadow .16s ease; }
.game-type-option:hover { transform: translateY(-2px); }
.game-type-option:focus-visible { outline: 3px solid #26332c; outline-offset: 3px; }
.game-type-option.selected { box-shadow: 0 0 0 2px #fffdf7, 0 0 0 4px #aeb99e; }
.turtle-arena { --game-card-start: #e6f2d9; --game-card-end: #f8f3d9; color: #42633e; }
.throne-arena { --game-card-start: #f7e5b7; --game-card-end: #f4d8cf; color: #87531f; }
.basketball-arena { --game-card-start: #b9dce9; --game-card-end: #e7e2f5; color: #3c6485; }
.territory-arena { --game-card-start: #c6dba7; --game-card-end: #e8edcf; color: #536c3d; }
.ants-castle-arena { --game-card-start: #d7a97e; --game-card-end: #f0dfc9; color: #75492f; }
.territory-lobby-icon { display: grid; width: 38px; height: 38px; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.territory-lobby-icon i { display: block; border: 1px solid #819273; border-radius: 2px; background: #f8f6eb; }
.territory-lobby-icon i:nth-child(1), .territory-lobby-icon i:nth-child(2), .territory-lobby-icon i:nth-child(4) { border-color: #536c3d; background: #71985c; }
.territory-lobby-icon i:nth-child(9) { border-color: #087a99; background: #08a8c7; }
.game-type-art { display: grid; flex: 0 0 60px; width: 60px; height: 60px; place-items: center; overflow: hidden; border: 1px solid #ffffffb3; border-radius: 16px; background: #ffffffa6; box-shadow: 0 5px 12px #26332c12; }
.game-type-art img { width: 100%; height: 100%; object-fit: cover; }
.throne-arena .game-type-art img { object-fit: contain; }
.game-type-art.basketball-art { font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; font-size: 44px; line-height: 1; }
.game-type-copy { display: grid; min-width: 0; gap: 4px; }
.game-type-copy strong { overflow: hidden; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(16px, 1.8vw, 21px); letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.game-type-copy small { color: #536057; font-size: 11px; font-weight: 650; letter-spacing: .025em; }
.game-type-favorite-toggle { position: absolute; z-index: 4; top: 2px; right: 2px; display: grid; width: 26px; height: 26px; place-items: center; padding: 0; border: 0; border-radius: 0; background: transparent; color: #e5ad18; font-size: 24px; line-height: 1; }
.game-type-favorite-toggle:hover { transform: scale(1.15); background: transparent; color: #e5ad18; }
.game-type-favorite-toggle.is-favorite { color: #e5ad18; }
.game-type-favorite-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.game-type-create-toggle { position: absolute; z-index: 3; top: 50%; right: 22px; display: grid; width: 42px; height: 42px; place-items: center; padding: 0 0 3px; border: 1px solid #ffffffb3; border-radius: 12px; background: #ffffffdf; color: var(--ink); font-size: 30px; font-weight: 500; line-height: 1; transform: translateY(-50%); }
.game-type-create-toggle:hover { transform: translateY(-50%) scale(1.06); background: #fff; }
.game-type-create-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.lobby-controls { display: grid; grid-template-columns: minmax(0, 1fr); align-items: end; gap: 12px; margin-bottom: 16px; }
.lobby-controls .lobby-search { margin: 0; }
.create-game-toggle { padding: 10px 14px; white-space: nowrap; }
#noGameSearchResults { margin: 16px 0; }
.lobby-game-tile { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background-color .2s ease; }
.lobby-game-tile:hover, .lobby-game-tile:focus-visible { transform: translateY(-2px); box-shadow: 0 14px 30px #56634826; outline: 3px solid #92a66b66; }
#games .game-card { position: relative; }
#games .game-card h3 { padding-right: 26px; font-size: 19px; }
#games .lobby-game-tile.my-turn { background: #e5f3df !important; }
#games .lobby-game-tile.waiting { background: #f9e4d2 !important; }
#games .lobby-game-tile.not-started { background: #f4ead2 !important; }
#games .lobby-game-tile.finished-won { background: #f8efbd !important; }
#games .lobby-game-tile.finished-lost { background: #e7e9e5 !important; }
.lobby-top-players { margin-top: 20px; padding: 18px; }
.lobby-top-players .section-head { margin-bottom: 14px; }
.lobby-top-players .section-head a { color: var(--green); font-size: 13px; font-weight: 750; }
.lobby-top-10, .lobby-top10 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.lobby-top-player { display: grid; grid-template-columns: 24px 34px minmax(0, 1fr); align-items: center; gap: 7px; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); text-decoration: none; }
.lobby-top-player:hover { border-color: #a9b99e; background: #f8fbf5; }
.lobby-top-rank { color: var(--muted); font-size: 13px; font-weight: 850; text-align: center; }
.lobby-top-player img { width: 34px; height: 34px; object-fit: contain; }
.lobby-top-details { display: grid; min-width: 0; gap: 2px; }
.lobby-top-details strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.lobby-top-details small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.finish-note { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; background: #e4f0a8; color: var(--ink); }
.finish-note strong { display: block; margin-bottom: 4px; }
.finish-note ol { margin: 0; padding-left: 22px; }
#results { display: none !important; }

.piece-center-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border: 1px solid #777;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 2px #26332c;
  pointer-events: none;
  z-index: 6;
}
.piece-center-dot { display: none !important; }

@media (max-width: 1000px) {
  .lobby-top10 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .below { grid-template-columns: 1fr 1fr; }
  #games .lobby-group > .games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .login { display: flex; }
  #games .lobby-group > .games { grid-template-columns: 1fr; }
  #games .lobby-group + .lobby-group { margin-top: 8px; }
  .game-type-choices { gap: 8px; }
  .game-type-option { min-height: 76px; gap: 9px; padding: 8px 52px 8px 8px; border-radius: 16px; }
  .game-type-art { flex-basis: 48px; width: 48px; height: 48px; border-radius: 14px; }
  .game-type-copy small { font-size: 10px; }
  .below { display: block; }
  .hand-panel { padding: 12px 10px; }
  .hand { gap: 5px; flex-wrap: nowrap; }
  .hand .card { flex: 1 1 0; width: 0; min-width: 0; height: auto; aspect-ratio: 78 / 104; }
}
@media (max-width: 520px) { .lobby-top10 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.lobby-search{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:10px}.lobby-search label{font-weight:750;color:var(--muted)}.lobby-search input{width:100%;background:var(--paper)}
#lobby.game-type-selected { transform: translateY(-40px); }
#turtleWaiting[hidden], #turtlePlaying[hidden] { display: none !important; }
.turtle-waiting-panel { padding: 24px; margin-top: 10px; }
.turtle-help { color: var(--muted); margin: 0 0 16px; font-size: 15px; line-height: 1.5; }
.turtle-waiting-players { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.turtle-waiting-players .chip-avatar { width: 32px; height: 32px; }
.turtle-waiting-players .player-chip > a:not(.chip-profile-link), #players .player-chip > a:not(.chip-profile-link) { font-weight: 750; }
.turtle-wait-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.turtle-wait-actions .muted { margin-right: auto; }
.turtle-npc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.turtle-npc-actions button { padding: 9px 13px; font-size: 13px; }
#turtleStart { padding: 10px 18px; font-weight: 800; }
@media(max-width:600px){.lobby-search{grid-template-columns:1fr;gap:5px}.lobby-search input{min-width:0}.game-type-picker-heading{align-items:flex-start;flex-direction:column;gap:3px}.game-type-choices{grid-template-columns:1fr;gap:8px}.game-type-option{min-height:64px}.game-type-art{flex-basis:46px;width:46px;height:46px}.game-type-copy strong{font-size:18px}}
