.portrait-hint { display: none; }
.phone-frame, .phone-screen { min-width: 0; }
.startup-stage { position: relative; min-width: 0; }
.startup-board { pointer-events: none; }
.startup-overlay { position: absolute; z-index: 3; top: 50%; left: 50%; width: min(390px, 86%); margin: 0; transform: translate(-50%, -50%); }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 7px; align-items: stretch; }
.board-stage { position: relative; min-width: 0; }
.waiting-overlay { position: absolute; z-index: 2; top: 50%; left: 50%; width: min(340px, 82%); padding: 22px 24px 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #d8d0c1; border-radius: 16px; background: #fffdf7; color: #173f3a; text-align: center; box-shadow: 0 14px 38px #17201d38; transform: translate(-50%, -50%); }
.waiting-overlay .connection { position: absolute; top: 10px; right: 12px; }
.waiting-overlay h2 { margin: 7px 0 12px; font-size: 18px; }
.waiting-overlay small { font-size: 8px; letter-spacing: 1.5px; }
.waiting-overlay strong { margin-top: 2px; font-size: 28px; letter-spacing: 5px; }
.waiting-overlay p { margin: 8px 0 0; font-size: 11px; color: #61706d; }
.board-wrap { min-width: 0; overflow: visible; margin: 0; padding: 0; }
.column-numbers, .column-progress, .column-score-row { display: grid; grid-template-columns: repeat(var(--columns, 15), minmax(0, 1fr)); gap: 3px; min-width: 0; }
.column-numbers { grid-template-columns: repeat(15, minmax(0, 1fr)); }
.column-numbers span { display: grid; place-items: center; height: 25px; margin: 0 0 3px; background: #fff; color: #111; border-radius: 5px; font-size: 13px; font-weight: 900; box-shadow: inset 0 -1px 0 #bbb; }
.board { min-width: 0; gap: 3px; padding: 3px; border-radius: 7px; background: #111; }
.cell { border-radius: 6px; min-width: 0; min-height: 0; }
.cell.marked::after { display: none; }
.cell.marked .mark { color: #111; text-shadow: none; transform: none; font-family: Arial, sans-serif; font-weight: 900; font-size: 19px; line-height: 1; }
.column-progress { margin-top: 4px; background: #111; padding: 3px; border-radius: 6px; }
.column-progress span { height: 21px; display: grid; place-items: center; background: #fff; color: #111; border-radius: 4px; font-size: 12px; font-weight: 900; }
.column-progress span.complete { color: #078c42; }
.column-score-row { background: #111; padding: 3px; }
.first-scores { margin-top: 4px; border-radius: 6px 6px 0 0; padding-bottom: 1px; }
.later-scores { border-radius: 0 0 6px 6px; padding-top: 1px; }
.column-score-row span { height: 21px; display: grid; place-items: center; background: #fff; color: #111; border-radius: 4px; font-size: 12px; font-weight: 900; position: relative; }
.column-score-row span.earned { outline: 2px solid #078c42; outline-offset: -3px; color: #078c42; }
.column-score-row span.unavailable { color: transparent; }
.column-score-row span.unavailable::after { content: "X"; position: absolute; inset: 0; display: grid; place-items: center; color: #111; font-family: Arial, sans-serif; font-size: 14px; font-weight: 900; line-height: 1; }
.completion { margin: 0; background: #111; color: #fff; border-radius: 7px; padding: 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.score-lines { display: grid; gap: 3px; }
.score-line { display: grid; grid-template-columns: 16px 1fr; gap: 3px; align-items: center; }
.score-check { font-size: 9px; text-align: center; }
.color-score { height: 25px; border-radius: 5px; display: grid; grid-template-columns: 1fr 1fr; place-items: stretch; color: #111; font-size: 13px; font-weight: 900; overflow: hidden; }
.color-score span { display: grid; place-items: center; position: relative; }
.color-score span + span { border-left: 1px solid #1115; }
.color-score span.earned { outline: 2px solid #087a5d; outline-offset: -3px; color: #087a5d; }
.color-score span.unavailable { color: transparent; }
.color-score span.unavailable::after { content: "X"; position: absolute; inset: 0; display: grid; place-items: center; color: #111; font-family: Arial, sans-serif; font-size: 14px; font-weight: 900; line-height: 1; }
.score-box { display: grid; grid-template-columns: 1fr 38px; align-items: center; gap: 3px; font-size: 9px; }
.score-box b { text-align: right; }
.score-box span { height: 22px; display: grid; place-items: center; background: #fff; color: #111; border-radius: 4px; font-size: 13px; font-weight: 900; }
.score-box.penalty span { color: #e52530; }
.score-box.positive span { color: #078c42; }
.score-box.total { margin-top: auto; }
.score-box.total span { border: 0; outline: 0; }
.board-toolbar { display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 6px; margin-top: 5px; padding: 4px 7px; background: #111; border-radius: 6px; color: #fff; }
.toolbar-jokers { display: flex; align-items: center; gap: 3px; }
.toolbar-jokers b { margin-right: 3px; font-size: 9px; letter-spacing: .4px; }
.board-toolbar button { min-height: 24px; height: 24px; min-width: 24px; padding: 0 5px; border: 0; border-radius: 5px; background: #fff; color: #111; font-size: 12px; font-weight: 900; }
.toolbar-jokers .joker { width: 22px; min-width: 22px; border-radius: 50%; border: 2px solid #111; outline: 1px solid #fff; font-size: 14px; }
.toolbar-jokers .joker { position: relative; }
.toolbar-jokers .joker.used { color: #d92732; opacity: .65; }
.toolbar-jokers .joker:disabled { opacity: 1; cursor: default; }
.toolbar-jokers .joker.used::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px; background: #d92732; transform: rotate(-38deg); }
.board-choices, .toolbar-actions { display: flex; gap: 3px; }
.board-choices button { position: relative; }
.board-choices button.completed { color: transparent; }
.board-choices button.completed::after { content: "X"; position: absolute; inset: 0; display: grid; place-items: center; color: #111; font-family: Arial, sans-serif; font-size: 15px; font-weight: 900; line-height: 1; }
.toolbar-actions { justify-self: end; }
.toolbar-turn { align-self: center; margin-right: 4px; color: #b9c2bf; font-size: 8px; font-weight: 900; white-space: nowrap; }
.toolbar-turn.active { color: #ffe052; }
.board-toolbar .confirm-move { min-width: 52px; background: #65aa75; color: #071e16; }
.board-toolbar .pass-move { min-width: 38px; background: #fff; }
.board-toolbar .confirm-move:disabled { opacity: .4; }
.board-choices button:disabled { opacity: 1; cursor: default; }
.cell:disabled { opacity: 1; cursor: not-allowed; }
.turn-status { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 4px; min-height: 27px; padding: 4px 9px; border-radius: 7px; text-align: center; font-size: 10px; font-weight: 800; }
.turn-status.your-turn { background: #173f3a; color: #fff; box-shadow: 0 0 0 2px #65aa75; }
.turn-status.your-turn strong { color: #ffe052; letter-spacing: .8px; }
.turn-status.waiting-turn { background: #e5dfd2; color: #596863; }
.game-error { margin: 4px 0 0; color: #a52222; text-align: center; font-size: 11px; font-weight: 700; }
.board-error { position: absolute; z-index: 4; left: 50%; bottom: 8px; width: max-content; max-width: 88%; margin: 0; padding: 5px 10px; border: 1px solid #d7aaa4; border-radius: 7px; background: #fffdf7ed; box-shadow: 0 5px 15px #32110d2b; transform: translateX(-50%); }
.game-end { margin-top: 5px; padding: 5px 9px; border-radius: 7px; background: #173f3a; color: #fff; text-align: center; font-size: 11px; font-weight: 800; }
.completion .legend { justify-content: center; gap: 7px; color: #fff; font-size: 7px; }
.completion .legend i { width: 6px; height: 6px; margin-right: 2px; }
.completion .legend i.mine { background: #fff; }
.score-live { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 13px; color: #fff; font-size: 8px; font-weight: 800; }
.score-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #d38a34; }
.score-live.online::before { background: #3caa63; }
.room-bar, .opponent { margin-bottom: 7px; }
.danger-text { margin: 5px auto 0; min-height: 27px; }
.turn-panel { display: flex; align-items: center; gap: 6px; margin: 0 0 7px; padding: 5px 7px; border-radius: 8px; background: #111; color: #fff; }
.turn-label { min-width: 105px; font-size: 10px; font-weight: 800; }
.dice { display: flex; gap: 4px; }
.turn-panel .die { width: 30px; height: 30px; min-height: 0; padding: 0; border: 2px solid #fff; border-radius: 6px; background: #fff; color: #111; font-size: 15px; }
.turn-panel .die.selected { outline: 3px solid #00d68f; outline-offset: 1px; }
.turn-panel .die:disabled { opacity: .32; }
.turn-panel .die.yellow { background: var(--yellow); }.turn-panel .die.green { background: var(--green); }.turn-panel .die.blue { background: var(--blue); }.turn-panel .die.pink { background: var(--pink); }.turn-panel .die.orange { background: var(--orange); }
.turn-panel .die.wild { background: #222; color: #fff; }
.turn-panel select { height: 28px; max-width: 72px; border-radius: 5px; font-size: 10px; }
.turn-panel .submit-move, .turn-panel .pass-move { min-height: 29px; padding: 2px 9px; border-color: #fff; border-radius: 6px; color: #fff; font-size: 10px; }
.turn-panel .submit-move { margin-left: auto; background: #087a5d; }
.selected-cell { outline: 3px solid #fff; outline-offset: -4px; box-shadow: inset 0 0 0 5px #111; transform: scale(.92); }
.cell .star { color: #fff; font-size: 22px; line-height: 1; text-shadow: 0 1px 2px #111; transform: none; }

@media (orientation: landscape) and (max-height: 500px) {
  body { padding: max(4px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); background: #ded9cc; }
  main { max-width: none; }
  .play-layout { grid-template-columns: minmax(0, calc((100vh - 205px) * 15 / 7)) 80px; justify-content: center; }
  .brand { display: none; }
  .room-bar { height: 28px; margin: 0 0 4px; }
  .room-bar small { font-size: 7px; }
  .room-bar strong { font-size: 15px; }
  .compact { min-height: 25px; padding: 2px 8px; }
  .opponent { padding: 5px 9px; border-radius: 8px; margin-bottom: 4px; box-shadow: none; }
  .opponent strong { font-size: 12px; }
  .mini-progress { font-size: 9px; }
  .waiting { padding: 8px; margin: 4px 0; }
  .waiting h2 { font-size: 14px; margin: 3px; }
  .waiting p { font-size: 10px; }
  .board { gap: 2px; padding: 3px; }
  .column-numbers, .column-progress, .column-score-row { gap: 2px; }
  .column-numbers span { height: 20px; font-size: 11px; margin-bottom: 2px; }
  .column-progress { margin-top: 3px; }
  .column-progress span { height: 18px; }
  .column-score-row span { height: 18px; font-size: 10px; }
  .cell { border-radius: 5px; }
  .cell span { font-size: 25px; }
  .color-score { height: 21px; }
  .score-box span { height: 19px; }
  .danger-text { display: none; }
  .turn-panel { height: 35px; margin-bottom: 4px; padding: 3px 6px; }
  .turn-panel .die { width: 25px; height: 25px; font-size: 12px; }
  .turn-panel select { height: 25px; }
  .board-toolbar { height: 31px; margin-top: 3px; padding: 3px 6px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .startup-overlay { width: min(350px, 78%); padding: 10px 14px; gap: 4px; border-radius: 13px; }
  .startup-overlay label { margin-top: 1px; font-size: 11px; }
  .startup-overlay input { min-height: 38px; padding: 7px 10px; border-radius: 9px; font-size: 14px; }
  .startup-overlay button { min-height: 38px; border-radius: 9px; font-size: 13px; }
  .startup-overlay .or { margin: 1px 0; }
  .startup-overlay .error { margin: 2px 0 0; font-size: 10px; }
}

@media (min-width: 900px) and (min-height: 550px) {
  body:has(.phone-frame) { min-height: 100vh; padding: 24px; background: radial-gradient(circle at 50% 35%, #faf5e9 0, #d8d1c3 70%); }
  body:has(.phone-frame) #app { display: grid; place-items: center; width: 100%; min-height: calc(100vh - 48px); }
  main:has(.phone-frame) { width: min(94vw, 900px); max-width: none; margin: auto; }
  .phone-frame { position: relative; width: 100%; padding: 12px 18px; border: 4px solid #262626; border-radius: 48px; background: #090909; box-shadow: 0 24px 70px #17201d45, inset 0 0 0 2px #555; }
  .phone-frame::before { content: ""; position: absolute; z-index: 4; top: 50%; left: 5px; width: 5px; height: 70px; border-radius: 4px; background: #353535; transform: translateY(-50%); }
  .phone-screen { position: relative; overflow: hidden; padding: 12px 16px 10px; border-radius: 31px; background: #efe9db; }
  .phone-screen::after { content: ""; position: absolute; z-index: 4; top: 50%; right: 5px; width: 6px; height: 6px; border: 3px solid #333; border-radius: 50%; background: #111; transform: translateY(-50%); }
}

@media (orientation: portrait) and (max-width: 600px) {
  main:has(.play-layout) > .room-bar,
  main:has(.play-layout) > .waiting,
  main:has(.play-layout) > .opponent,
  main:has(.play-layout) > .play-layout,
  main:has(.play-layout) > .danger-text,
  main:has(.play-layout) > .brand { display: none; }
  .portrait-hint { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: var(--paper); padding: 30px; }
  .portrait-hint span { font-size: 54px; }
  .portrait-hint strong { font-size: 22px; }
  .portrait-hint small { margin-top: 7px; color: #61706d; }
}
