/*
  Focused rebuild Phase 2 — Crossword-Master-style game screen.
  -------------------------------------------------------------
  This layer deliberately strips the old dark arena/card chrome from Duel play
  and makes the Scandinavian Arrowword board the dominant surface. It changes
  presentation only: canonical geometry, scoring, rack authority, rewarded tool
  logic, AI/Friend authority and persistence remain in their existing modules.
*/
:root{
  --cm2-blue:#3899e6;
  --cm2-blue-deep:#2487d5;
  --cm2-clue:#dceef9;
  --cm2-clue-active:#cfe8f8;
  --cm2-grid:#b9c4cc;
  --cm2-wall:#f0f3f5;
  --cm2-answer:#fff;
  --cm2-active:#fff0d8;
  --cm2-active-line:#eab45b;
  --cm2-hint:#dff1d4;
  --cm2-hint-line:#83bf67;
  --cm2-tile:#fff2d6;
  --cm2-tile-edge:#dfc58f;
  --cm2-ink:#20252c;
  --cm2-muted:#8b9299;
}

html.mobile-game-active,
html.mobile-game-active body,
html.mobile-game-active #app{background:#fff!important}
html.mobile-game-active body{overflow:hidden!important}

/* One continuous game canvas. No desktop card, no dark arena, no decorative shell. */
.cm-phase2-screen{
  width:100vw!important;
  max-width:none!important;
  height:var(--vvh,100dvh)!important;
  min-height:var(--vvh,100dvh)!important;
  max-height:var(--vvh,100dvh)!important;
  margin:0!important;
  padding:max(2px,var(--native-top,0px)) max(8px,var(--native-right,0px)) max(5px,var(--native-bottom,0px)) max(8px,var(--native-left,0px))!important;
  display:grid!important;
  grid-template-rows:50px 50px minmax(0,1fr) 116px!important;
  gap:0!important;
  overflow:hidden!important;
  background:#fff!important;
  color:var(--cm2-ink)!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  isolation:isolate;
}
.cm-phase2-screen:before,.cm-phase2-screen:after{display:none!important;content:none!important}

/* Reference-like native header. */
.cm-phase2-screen .duel-compact-top{
  width:min(var(--cm-board-px,720px),calc(100vw - 16px))!important;
  height:50px!important;min-height:50px!important;
  margin:0 auto!important;padding:0!important;
  display:grid!important;grid-template-columns:44px 1fr 44px!important;align-items:center!important;
  border:0!important;border-radius:0!important;background:#fff!important;box-shadow:none!important;backdrop-filter:none!important;
}
.cm-phase2-screen .duel-compact-top:after{display:none!important;content:none!important}
.cm-phase2-screen .duel-compact-top .back,
.cm-phase2-screen .cm-settings{
  width:40px!important;height:40px!important;min-width:40px!important;min-height:40px!important;
  display:grid!important;place-items:center!important;margin:0!important;padding:0!important;
  border:0!important;border-radius:50%!important;background:transparent!important;box-shadow:none!important;
  color:var(--cm2-blue)!important;font-size:22px!important;line-height:1!important;
}
.cm-phase2-screen .duel-compact-top .back:hover,
.cm-phase2-screen .cm-settings:hover{background:#f4f8fb!important}
.cm-phase2-screen .duel-compact-top .back .ui-icon{width:24px!important;height:24px!important;stroke-width:2!important}
.cm-phase2-screen .duel-title{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;text-align:center!important;min-width:0!important}
.cm-phase2-screen .duel-title b{font-size:18px!important;line-height:1.05!important;font-weight:720!important;color:#161b21!important;letter-spacing:-.018em!important}
.cm-phase2-screen .duel-title small{margin-top:3px!important;font-size:9px!important;line-height:1!important;font-weight:560!important;color:#9aa0a7!important;letter-spacing:.025em!important;text-transform:none!important}
.cm-phase2-screen .friend-resign.cm-settings{font-size:24px!important;color:#7d858d!important}

/* Score is a simple line directly above the board: You [score] vs [score] Opponent. */
.cm-phase2-screen .aw-scorebar{
  width:min(var(--cm-board-px,720px),calc(100vw - 16px))!important;
  height:50px!important;min-height:50px!important;
  margin:0 auto!important;padding:3px 7px 7px!important;
  display:grid!important;grid-template-columns:minmax(0,1fr) 46px minmax(0,1fr)!important;align-items:center!important;
  border:0!important;border-radius:0!important;background:#fff!important;box-shadow:none!important;overflow:visible!important;color:var(--cm2-ink)!important;
}
.cm-phase2-screen .aw-scorebar:before,.cm-phase2-screen .aw-scorebar:after{display:none!important;content:none!important}
.cm-phase2-screen .duelist{display:flex!important;align-items:center!important;gap:8px!important;min-width:0!important;padding:0!important;background:transparent!important;transform:none!important;filter:none!important}
.cm-phase2-screen .duelist.ai{justify-content:flex-end!important}
.cm-phase2-screen .duelist:after{display:none!important;content:none!important}
.cm-phase2-screen .duelist>div{display:flex!important;align-items:center!important;gap:0!important;min-width:0!important}
.cm-phase2-screen .duelist small{display:none!important}
.cm-phase2-screen .duelist .avatar{
  width:auto!important;height:auto!important;min-width:0!important;padding:0!important;
  border:0!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;
  color:#30363d!important;font-size:15px!important;font-weight:500!important;letter-spacing:0!important;text-transform:none!important;
}
.cm-phase2-screen .duelist.ai .avatar{max-width:118px!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;text-align:right!important}
.cm-phase2-screen .duelist b{
  min-width:38px!important;height:30px!important;margin:0 0 0 8px!important;padding:0 8px!important;
  display:grid!important;place-items:center!important;border:0!important;border-radius:6px!important;
  background:#f2f4f5!important;color:#a1a5a9!important;box-shadow:none!important;text-shadow:none!important;
  font-size:19px!important;line-height:1!important;font-weight:690!important;
}
.cm-phase2-screen .duelist.ai>div b{order:-1;margin:0 8px 0 0!important}
.cm-phase2-screen .duelist.active b{background:#edf7ff!important;color:var(--cm2-blue)!important}
.cm-phase2-screen .duel-vs{height:100%!important;display:grid!important;place-items:center!important;position:relative!important;min-width:0!important}
.cm-phase2-screen .duel-vs>span{font-size:13px!important;font-weight:520!important;color:#9aa0a6!important;letter-spacing:0!important;text-transform:lowercase!important;background:transparent!important;padding:0!important}
.cm-phase2-screen .duel-vs>i,.cm-phase2-screen .duel-vs>strong,.cm-phase2-screen .duel-vs>.duel-phase-cue{display:none!important}

/* Board has no parent card. Its own thin gridline is the only frame. */
.cm-phase2-screen .duel-board-stage{
  align-self:center!important;justify-self:center!important;
  width:min(var(--cm-board-px,720px),calc(100vw - 16px))!important;
  height:100%!important;min-height:0!important;max-width:none!important;
  margin:0 auto!important;padding:0!important;
  display:grid!important;place-items:center!important;overflow:hidden!important;
  border:0!important;border-radius:0!important;background:#fff!important;box-shadow:none!important;backdrop-filter:none!important;
}
.cm-phase2-screen .duel-board-stage:before,.cm-phase2-screen .duel-board-stage:after{display:none!important;content:none!important}
.cm-phase2-screen .aw-scroller{
  width:100%!important;height:100%!important;min-height:0!important;max-height:none!important;
  display:grid!important;place-items:center!important;margin:0!important;padding:0!important;overflow:hidden!important;
  background:#fff!important;border:0!important;border-radius:0!important;box-shadow:none!important;
}
.cm-phase2-screen .aw-grid{
  gap:1px!important;padding:0!important;margin:auto!important;
  max-width:100%!important;max-height:100%!important;
  background:var(--cm2-grid)!important;border:1px solid var(--cm2-grid)!important;border-radius:0!important;
  box-shadow:none!important;filter:none!important;transform:none!important;
}
.cm-phase2-screen .aw-cell{border:0!important;border-radius:0!important;box-shadow:none!important;outline-offset:-2px!important}
.cm-phase2-screen .true-arrowword-grid .aw-wall{background:var(--cm2-wall)!important;box-shadow:none!important}
.cm-phase2-screen .true-arrowword-grid .aw-clue{
  padding:3px 3px 11px!important;background:var(--cm2-clue)!important;color:#26313a!important;
  border:0!important;border-radius:0!important;box-shadow:none!important;filter:none!important;text-align:center!important;
}
.cm-phase2-screen .true-arrowword-grid .aw-clue.complete{background:var(--cm2-clue)!important}
.cm-phase2-screen .true-arrowword-grid .aw-clue.active{background:var(--cm2-clue-active)!important;box-shadow:inset 0 0 0 2px var(--cm2-blue)!important;z-index:3!important}
.cm-phase2-screen .aw-clue-copy{width:100%!important;height:100%!important;display:grid!important;place-items:center!important}
.cm-phase2-screen .aw-clue-copy b{
  font-size:clamp(6px,calc(var(--aw-cell)*.145),10.5px)!important;line-height:1.02!important;font-weight:650!important;letter-spacing:-.015em!important;
  -webkit-line-clamp:4!important;text-wrap:balance!important;
}
.cm-phase2-screen .aw-clue.emoji{padding:2px 2px 10px!important}
.cm-phase2-screen .aw-clue .aw-emoji{font-size:calc(var(--aw-cell)*.48)!important;line-height:1!important}
.cm-phase2-screen .aw-directions{right:2px!important;bottom:1px!important;gap:0!important}
.cm-phase2-screen .aw-directions i{width:12px!important;height:12px!important;display:grid!important;place-items:center!important;border-radius:0!important;background:transparent!important;color:#66737d!important;font-size:10px!important;font-weight:800!important;filter:none!important}
.cm-phase2-screen .aw-directions i.on{background:transparent!important;color:#415462!important}
.cm-phase2-screen .aw-clue em{display:none!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer{
  background:var(--cm2-answer)!important;color:#242930!important;border:0!important;border-radius:0!important;
  font-size:calc(var(--aw-cell)*.46)!important;font-weight:700!important;box-shadow:none!important;
}
.cm-phase2-screen .true-arrowword-grid .aw-answer.locked{background:#fff!important;color:#242930!important}
/* Selection follows the reference's warm word highlight; hint remains green. */
.cm-phase2-screen .true-arrowword-grid .aw-answer.lane{background:var(--cm2-active)!important;box-shadow:inset 0 0 0 1px rgba(234,180,91,.7)!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.lane-open{background:var(--cm2-active)!important;box-shadow:inset 0 0 0 2px var(--cm2-active-line)!important;animation:none!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.buffered{background:#fff0d6!important;color:#242930!important;box-shadow:inset 0 0 0 2px var(--cm2-active-line)!important;animation:cm2-place .16s ease-out!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.buffered .aw-return{color:#9d7a43!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.ai-preview{background:#e8f4df!important;color:#242930!important;box-shadow:inset 0 0 0 2px #8fc978!important;animation:cm2-place .18s ease-out both!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.hint-target{background:var(--cm2-hint)!important;box-shadow:inset 0 0 0 2px var(--cm2-hint-line)!important;z-index:2!important}
.cm-phase2-screen .true-arrowword-grid .aw-answer.hint-target-lane{background:#d6ecc9!important;box-shadow:inset 0 0 0 3px #73b256!important}
.cm-phase2-screen .aw-answer.drag-target{background:#edf7ff!important;box-shadow:inset 0 0 0 2px var(--cm2-blue)!important;transform:none!important}

/* Rack is directly attached to play, not in a card. */
.cm-phase2-screen .aw-dock{
  position:relative!important;bottom:auto!important;z-index:10!important;
  width:min(var(--cm-board-px,720px),calc(100vw - 16px))!important;
  height:116px!important;min-height:116px!important;margin:0 auto!important;padding:3px 0 2px!important;
  display:grid!important;grid-template-rows:64px 47px!important;gap:0!important;overflow:visible!important;
  background:#fff!important;border:0!important;border-radius:0!important;box-shadow:none!important;backdrop-filter:none!important;filter:none!important;
}
.cm-phase2-screen .aw-dock.waiting{opacity:1!important}
.cm-phase2-screen .aw-rack{
  height:64px!important;min-height:64px!important;margin:0!important;padding:0!important;
  display:flex!important;align-items:center!important;justify-content:center!important;gap:clamp(7px,1.4vw,11px)!important;overflow:visible!important;
}
.cm-phase2-screen .aw-tile{
  position:relative!important;width:54px!important;height:56px!important;min-width:54px!important;min-height:56px!important;margin:0!important;padding:0!important;
  display:grid!important;place-items:center!important;border:1px solid #ead8b3!important;border-radius:7px!important;
  background:linear-gradient(180deg,#fff8e9 0%,var(--cm2-tile) 100%)!important;color:#24282e!important;
  box-shadow:0 3px 0 var(--cm2-tile-edge),0 5px 10px rgba(68,54,28,.10)!important;transform:none!important;
  transition:transform .12s ease,box-shadow .12s ease!important;
}
.cm-phase2-screen .aw-tile span{font-size:22px!important;line-height:1!important;font-weight:720!important}
.cm-phase2-screen .aw-tile small{display:none!important}
.cm-phase2-screen .aw-tile.selected{transform:translateY(-4px)!important;border-color:#ddb66d!important;background:linear-gradient(180deg,#fff9ec,#ffefcf)!important;box-shadow:0 3px 0 #d5b06c,0 7px 12px rgba(69,54,25,.12),0 0 0 2px rgba(56,153,230,.23)!important}
.cm-phase2-screen .aw-tile.used{display:none!important}
.cm-phase2-screen .aw-rack.bonus-rack{gap:clamp(5px,1vw,8px)!important}
.cm-phase2-screen .aw-rack.bonus-rack .aw-tile{width:50px!important;min-width:50px!important}
.cm-phase2-screen .aw-tile.bonus-tile:after{content:'+';position:absolute;right:2px;top:2px;width:13px;height:13px;border-radius:50%;display:grid;place-items:center;background:var(--cm2-blue);color:#fff;font-size:9px;font-weight:800}

/* Four visible positions, as in the reference: two utilities, one dominant turn
   action, one hint. Pass becomes Submit once letters are staged. */
.cm-phase2-screen .gameplay-tools-actions.cm2-actions,
.cm-phase2-screen .cm2-actions{
  width:min(520px,100%)!important;height:47px!important;margin:0 auto!important;padding:0 3px!important;
  display:grid!important;grid-template-columns:52px 52px minmax(150px,270px) 52px!important;grid-template-rows:47px!important;
  align-items:center!important;justify-content:center!important;gap:clamp(8px,2vw,16px)!important;
}
.cm-phase2-screen .cm2-actions .gameplay-tool{
  margin:0!important;padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;color:#6f7880!important;
  min-width:0!important;min-height:0!important;border-radius:0!important;transform:none!important;filter:none!important;
}
.cm-phase2-screen .cm2-utility{
  width:46px!important;height:46px!important;display:grid!important;grid-template-columns:1fr!important;grid-template-rows:29px 11px!important;place-items:center!important;position:relative!important;
}
.cm-phase2-screen .cm2-utility>span{width:29px!important;height:29px!important;display:grid!important;place-items:center!important;border:1px solid #dce1e5!important;border-radius:50%!important;background:#fff!important;color:#65717a!important;font-size:17px!important;line-height:1!important}
.cm-phase2-screen .cm2-utility>b{font-size:8px!important;line-height:1!important;font-weight:600!important;color:#899198!important;white-space:nowrap!important}
.cm-phase2-screen .cm2-utility>small{position:absolute!important;right:1px!important;top:0!important;width:15px!important;height:15px!important;display:grid!important;place-items:center!important;border-radius:50%!important;background:var(--cm2-blue)!important;color:#fff!important;font-size:6px!important;font-weight:800!important;line-height:1!important;text-transform:uppercase!important;letter-spacing:0!important;margin:0!important}
.cm-phase2-screen .cm2-primary{
  grid-column:3!important;grid-row:1!important;width:100%!important;height:40px!important;min-height:40px!important;
  display:flex!important;align-items:center!important;justify-content:center!important;gap:7px!important;position:relative!important;
  border:0!important;border-radius:21px!important;background:var(--cm2-blue)!important;color:#fff!important;box-shadow:none!important;
  font-size:14px!important;font-weight:680!important;
}
.cm-phase2-screen .cm2-primary>span{font-size:15px!important;line-height:1!important;color:#fff!important}
.cm-phase2-screen .cm2-primary>b{font-size:14px!important;line-height:1!important;font-weight:680!important;color:#fff!important}
.cm-phase2-screen .cm2-primary>em{position:absolute!important;right:9px!important;top:50%!important;transform:translateY(-50%)!important;min-width:18px!important;height:18px!important;padding:0 5px!important;display:grid!important;place-items:center!important;border-radius:10px!important;background:rgba(255,255,255,.20)!important;color:#fff!important;font-size:9px!important;font-style:normal!important}
.cm-phase2-screen .cm2-primary:not(:disabled):active{transform:scale(.985)!important;background:var(--cm2-blue-deep)!important}
.cm-phase2-screen .cm2-primary:disabled{opacity:.38!important;background:#acd5f3!important}
.cm-phase2-screen .cm2-hint{grid-column:4!important}
.cm-phase2-screen .cm2-extra{grid-column:1!important}.cm-phase2-screen .cm2-swap{grid-column:2!important}
.cm-phase2-screen .cm2-hidden{display:none!important}
.cm-phase2-screen .cm2-utility:disabled{opacity:.34!important}
.cm-phase2-screen .friend-cm2-actions{grid-template-columns:52px minmax(150px,270px) 52px!important;width:min(430px,100%)!important}
.cm-phase2-screen .friend-cm2-actions .cm2-swap{grid-column:1!important}
.cm-phase2-screen .friend-cm2-actions .cm2-primary{grid-column:2!important}
.cm-phase2-screen .friend-cm2-actions .cm2-hint{grid-column:3!important}
.cm-phase2-screen .rewarded-tool-status{position:absolute!important;left:50%!important;bottom:0!important;transform:translateX(-50%)!important;z-index:15!important;padding:4px 8px!important;border-radius:10px!important;background:#fff!important;color:#70777d!important;font-size:9px!important;font-weight:600!important;box-shadow:0 2px 12px rgba(20,30,40,.10)!important;white-space:nowrap!important}

@keyframes cm2-place{0%{transform:scale(.86);opacity:.5}100%{transform:none;opacity:1}}

/* Tablet / desktop: enlarge the crossword, not a surrounding card. */
@media(min-width:521px){
  .cm-phase2-screen{grid-template-rows:46px 48px minmax(0,1fr) 112px!important;padding-left:12px!important;padding-right:12px!important}
  .cm-phase2-screen .duel-compact-top{height:46px!important;min-height:46px!important}
  .cm-phase2-screen .duel-title b{font-size:18px!important}.cm-phase2-screen .duel-title small{font-size:9px!important}
  .cm-phase2-screen .aw-scorebar{height:48px!important;min-height:48px!important;padding-bottom:5px!important}
  .cm-phase2-screen .duelist .avatar{font-size:15px!important}.cm-phase2-screen .duelist b{height:30px!important;font-size:19px!important}
  .cm-phase2-screen .aw-dock{height:112px!important;min-height:112px!important;grid-template-rows:63px 47px!important}
  .cm-phase2-screen .aw-rack{height:63px!important}
}

/* Phone: compact but still reference-like. */
@media(max-width:520px){
  .cm-phase2-screen{grid-template-rows:44px 44px minmax(0,1fr) 105px!important;padding-left:max(3px,var(--native-left,0px))!important;padding-right:max(3px,var(--native-right,0px))!important}
  .cm-phase2-screen .duel-compact-top{height:44px!important;min-height:44px!important;grid-template-columns:40px 1fr 40px!important}
  .cm-phase2-screen .duel-compact-top .back,.cm-phase2-screen .cm-settings{width:36px!important;height:36px!important;min-width:36px!important;min-height:36px!important}
  .cm-phase2-screen .duel-title b{font-size:16px!important}.cm-phase2-screen .duel-title small{font-size:8px!important;margin-top:2px!important}
  .cm-phase2-screen .aw-scorebar{height:44px!important;min-height:44px!important;padding:1px 6px 5px!important;grid-template-columns:minmax(0,1fr) 38px minmax(0,1fr)!important}
  .cm-phase2-screen .duelist{gap:5px!important}.cm-phase2-screen .duelist .avatar{font-size:13px!important}.cm-phase2-screen .duelist b{min-width:33px!important;height:27px!important;font-size:16px!important;margin-left:5px!important;padding:0 6px!important}.cm-phase2-screen .duelist.ai>div b{margin:0 5px 0 0!important}
  .cm-phase2-screen .duel-vs>span{font-size:11px!important}
  .cm-phase2-screen .aw-dock{height:105px!important;min-height:105px!important;grid-template-rows:58px 45px!important;padding-top:1px!important}
  .cm-phase2-screen .aw-rack{height:58px!important;gap:6px!important}
  .cm-phase2-screen .aw-tile{width:clamp(43px,13vw,51px)!important;height:51px!important;min-width:43px!important;min-height:51px!important;border-radius:6px!important}
  .cm-phase2-screen .aw-tile span{font-size:20px!important}
  .cm-phase2-screen .aw-rack.bonus-rack .aw-tile{width:clamp(39px,11.5vw,46px)!important;min-width:39px!important}
  .cm-phase2-screen .gameplay-tools-actions.cm2-actions,.cm-phase2-screen .cm2-actions{height:45px!important;grid-template-columns:42px 42px minmax(118px,210px) 42px!important;gap:clamp(5px,1.8vw,10px)!important;padding:0!important}
  .cm-phase2-screen .cm2-utility{width:40px!important;height:42px!important;grid-template-rows:27px 10px!important}.cm-phase2-screen .cm2-utility>span{width:27px!important;height:27px!important;font-size:15px!important}.cm-phase2-screen .cm2-utility>b{font-size:7px!important}.cm-phase2-screen .cm2-utility>small{width:13px!important;height:13px!important;font-size:5.5px!important}
  .cm-phase2-screen .cm2-primary{height:38px!important;min-height:38px!important;border-radius:20px!important}.cm-phase2-screen .cm2-primary>b{font-size:13px!important}
  .cm-phase2-screen .friend-cm2-actions{grid-template-columns:42px minmax(145px,220px) 42px!important}
  .cm-phase2-screen .true-arrowword-grid .aw-clue{padding:2px 2px 9px!important}
}

@media(max-height:650px) and (max-width:520px){
  .cm-phase2-screen{grid-template-rows:40px 40px minmax(0,1fr) 96px!important}
  .cm-phase2-screen .duel-compact-top{height:40px!important;min-height:40px!important}.cm-phase2-screen .aw-scorebar{height:40px!important;min-height:40px!important}
  .cm-phase2-screen .aw-dock{height:96px!important;min-height:96px!important;grid-template-rows:53px 41px!important}.cm-phase2-screen .aw-rack{height:53px!important}.cm-phase2-screen .aw-tile{height:47px!important;min-height:47px!important}
  .cm-phase2-screen .gameplay-tools-actions.cm2-actions,.cm-phase2-screen .cm2-actions{height:41px!important;grid-template-rows:41px!important}.cm-phase2-screen .cm2-primary{height:36px!important;min-height:36px!important}
}

/* Accessibility preferences remain authoritative. */
.reduced-motion .cm-phase2-screen *{animation:none!important;transition:none!important}
.high-contrast .cm-phase2-screen .aw-grid{background:#000!important;border-color:#000!important}
.high-contrast .cm-phase2-screen .true-arrowword-grid .aw-clue{background:#dcecff!important;color:#000!important}
.high-contrast .cm-phase2-screen .true-arrowword-grid .aw-answer{color:#000!important}
.high-contrast .cm-phase2-screen .true-arrowword-grid .aw-wall{background:#eee!important}
.high-contrast .cm-phase2-screen .cm2-primary{background:#005bd7!important;color:#fff!important}
