/* Phone layouts share the palette selected by appearance.js. */
@media screen and (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  html[data-acex-page] .acex-topbar {
    position: relative; inset: auto; height: auto; flex-wrap: wrap;
    justify-content: space-between; padding: 12px 16px; gap: 10px;
  }
  html[data-acex-page] .acex-topbar nav {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start;
    flex: 1 1 100%; width: 100%; min-width: 0; gap: 4px;
  }
  html[data-acex-page] .acex-topbar nav a:not([hidden]) {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 6px 10px; margin: 0; gap: 5px;
    font-size: 13px; line-height: 1.3; white-space: nowrap; box-sizing: border-box;
    border-radius: 9px; background: var(--ax-soft); color: var(--ax-ink);
  }
  html[data-acex-page] .acex-topbar nav a span { display: inline; }
  html[data-acex-page] .acex-topbar nav select { height: 44px; min-height: 44px !important; }
  html[data-acex-page] .acex-topbar nav [hidden] { display: none !important; }
  html[data-acex-page] :is(main, section, form, label, .panel, .hero-copy, .menu-card, .topline > *) { min-width: 0; box-sizing: border-box; }
  html[data-acex-page] :is(input:not([type=checkbox]):not([type=radio]),select,textarea),
  body.workspace :is(input,select,textarea) { max-width: 100%; min-width: 0; box-sizing: border-box; font-size: 16px; }
  html[data-acex-page=home] .hero-copy .primary {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 8px 14px; margin: 4px 2px; box-sizing: border-box;
  }
  html[data-acex-page=home] .hero-art { overflow: hidden; min-width: 0; }
  html[data-acex-page=login] .account-links {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 20px;
  }
  html[data-acex-page=login] .account-links a { margin: 0; padding: 8px 4px; text-align: center; }
  html[data-acex-page=login] [aria-label="로그인 유형"] { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  html[data-acex-page=dashboard] .topline { flex-wrap: wrap; gap: 10px; }
  html[data-acex-page=dashboard] #eventSelect { max-width: 100%; }
  html[data-acex-page=dashboard] aside :is(a,button)::first-letter { font-size: inherit; }
  html[data-acex-page=dashboard] #workspaceTabs { max-width: 100%; overflow-x: auto; }
  .plan-table { overflow-x: auto; }
  .plan-table table { width: 100%; }
  body.workspace header nav { display: flex; flex-wrap: wrap; gap: 6px; }
  body.workspace header a { display: inline-flex; align-items: center; min-height: 44px; margin: 0; padding: 0 8px; }
  body.workspace main { padding: 14px; }
  body.workspace details form { display: grid; grid-template-columns: minmax(0,1fr); align-items: stretch; }
  body.workspace form :is(input:not([type=checkbox]), select, textarea, button) { width: 100%; min-height: 44px; }
  body.workspace label:has(input[type=checkbox]) { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
  body.workspace :is(output,#message) { overflow-wrap: anywhere; }
  .screen main:has(.pair-card) {
    box-sizing: border-box; height: auto; min-height: 100vh; min-height: 100svh;
    grid-template-columns: minmax(0,1fr); padding: 20px; overflow: visible;
  }
  .pair-card { box-sizing: border-box; width: min(100%,420px); margin: auto; padding: 20px 16px;
    background: #242329; border: 1px solid #43404a; border-radius: 16px; }
  .pair-card h1 { font-size: 26px; margin: 0 0 16px; }
  .screen .pair-card svg { display: block; width: min(100%,32vh,270px); height: auto; margin: 0 auto; }
  .pair-card small { display: block; overflow-wrap: anywhere; font-family: monospace; }
}
@media screen and (max-width: 480px) {
  html[data-acex-page=home] section.links { grid-template-columns: minmax(0,1fr); }
  html[data-acex-page=home] section.hero { gap: 16px; padding: 24px 0; }
  html[data-acex-page=home] .hero-art { height: 150px !important; }
  html[data-acex-page] .notice-dialog { max-width: calc(100vw - 24px); max-height: 85vh; overflow-y: auto; }
}
@media screen and (max-width: 600px) {
  html[data-acex-page=plans] .plan-table table { min-width: 0; border-collapse: separate; border-spacing: 0; }
  html[data-acex-page=plans] .plan-table :is(table,tbody) { display: block; }
  .plan-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .plan-table tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin-bottom: 12px; border: 1px solid var(--ax-line,#555); border-radius: 12px; padding: 12px; }
  .plan-table td { white-space: normal; border: 0; padding: 6px; font-size: 15px; text-align: start; }
  .plan-table td:first-child { grid-column: 1/-1; font-weight: bold; font-size: 18px; }
  .plan-table td::before { display: block; font-size: 12px; opacity: .8; }
  .plan-table td:nth-child(2)::before { content: '월 이용료'; }
  .plan-table td:nth-child(3)::before { content: '연 이용료'; }
  .plan-table td:nth-child(4)::before { content: '동시 대회'; }
  .plan-table td:nth-child(5)::before { content: 'TV 대수'; }
}
@media screen and (max-width: 600px) {
  html[data-acex-page=dashboard] .filter-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
  html[data-acex-page=dashboard] .filter-tabs button { min-width: 0; min-height: 44px; }
  html[data-acex-page=poster] #poster { width: 100%; min-height: 0; border-width: 5px; padding: 18px 12px; overflow-wrap: anywhere; }
  #poster .stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  #poster .stats div { padding: 8px; }
  #poster #reward { font-size: clamp(20px,6vw,32px); }
  #poster table { font-variant-numeric: tabular-nums; }
  #poster :is(th,td) { padding: 6px 2px; font-size: 12px; }
}

/* Match the space available to the home page, including fold and split view. */
@media screen and (max-width: 1100px) {
  html[data-acex-page=home] main {
    width: 100%; box-sizing: border-box; margin-inline: auto;
    padding-inline: clamp(12px, 3vw, 32px);
  }
  html[data-acex-page=home] .acex-topbar {
    position: relative; height: auto; flex-wrap: wrap; gap: 8px 16px;
    padding-inline: clamp(12px, 3vw, 32px);
  }
  html[data-acex-page=home] .acex-topbar nav {
    flex-wrap: wrap; min-width: 0; max-width: 100%; height: auto;
  }
  html[data-acex-page=home] section.links {
    display: grid; gap: clamp(8px, 1.8vw, 18px);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  }
  html[data-acex-page=home] section.links .menu-card { min-width: 0; }
  html[data-acex-page=home] section.hero {
    grid-template-columns: minmax(0,1fr);
    gap: clamp(12px, 2.8vw, 28px); padding-block: clamp(18px,4vw,44px);
  }
  html[data-acex-page=home] .hero h1 { font-size: clamp(29px,6vw,48px); }
  html[data-acex-page=home] .hero-art {
    min-width: 0; max-width: 100%; height: clamp(120px,32vw,210px) !important; overflow: hidden;
  }
  html[data-acex-page=home] .hero-copy { min-width: 0; overflow-wrap: anywhere; }
}
@media screen and (min-width: 680px) and (max-width: 1100px) {
  html[data-acex-page=home] section.hero {
    grid-template-columns: minmax(0,1.15fr) minmax(0,.85fr); align-items: center;
  }
  html[data-acex-page=home] .hero-art { height: clamp(210px,30vw,320px) !important; }
}
#planCatalogue { display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,13rem),1fr));gap:8px;margin-block:14px }
#planCatalogue a,.locked-feature,#upgradeDialog a {display:inline-flex;align-items:center;min-height:44px;padding:8px 12px;border-radius:9px;box-sizing:border-box;text-decoration:none}
#planCatalogue a,#upgradeDialog a {background:#33313a;color:#fff}
button.locked-feature,.workspace button.locked-feature {background:#292830;color:#f2ede3;border:1px solid #736959;cursor:pointer;text-align:start;font:inherit}
.workspace button.locked-feature {display:flex;width:100%;margin-block:10px}
#upgradeDialog {max-width:min(26rem,90vw);border:1px solid #79716a;border-radius:14px;padding:20px;background:#242329;color:#fff}
#upgradeDialog::backdrop {background:#0009}
#upgradeForm:not([hidden]) {display:flex;align-items:end;gap:12px;flex-wrap:wrap}
#upgradeForm[hidden] {display:none!important}
html[data-acex-page]{--ax-canvas:#f5f5f4;--ax-surface:#fff;--ax-ink:#202124;--ax-muted:#5f6268;--ax-line:#dadbdd;--ax-primary:#36383d;--ax-soft:#efefef}
html[data-acex-page][data-appearance=dark]{--ax-canvas:#141518;--ax-surface:#212226;--ax-ink:#f6f6f5;--ax-muted:#bec0c4;--ax-line:#414348;--ax-primary:#e6d3a9;--ax-soft:#303136}
html[data-acex-page] .acex-topbar{background:#202125;color:#fafafa}
html[data-acex-page] .acex-topbar nav a:not([hidden]){background:#303136;color:#f8f8f7!important}
html[data-acex-page] .acex-topbar .acex-emblem {color:#efddb8}
html[data-acex-page=home] .hero-art{background:radial-gradient(ellipse at 82% 16%,#55504a,transparent 64%),linear-gradient(135deg,#24252a,#17181b)!important;box-shadow:0 12px 36px #16171920!important;overflow:hidden}
.hero-art .hero-emblem{background:#efdfc3}
html[data-acex-page=home] .hero h1,html[data-acex-page=home] .hero h1 em{color:var(--ax-ink)}
html[data-acex-page=home] .home-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;max-width:32rem}
html[data-acex-page=home] .home-actions a.primary{display:flex;align-items:center;justify-content:center;min-width:0;max-width:100%;margin:0;min-height:46px;height:auto;line-height:1.35;padding:9px 8px;white-space:normal;overflow-wrap:anywhere;text-align:center;background:#303136;color:white!important}
html[data-acex-page=home] .home-actions a.tv-action{background:#ebd9b6;color:#28231c!important}
html[data-acex-page=home] .links .menu-card{background:var(--ax-surface);border:1px solid var(--ax-line);color:var(--ax-ink)}
html[data-acex-page=home] .links .menu-card i{background:var(--ax-soft)!important;color:var(--ax-ink)!important}
@media(max-width:760px){
 html[data-acex-page] .acex-topbar nav a:not([hidden]){white-space:normal;overflow-wrap:anywhere;max-width:100%}
 html[data-acex-page=home] .acex-topbar nav{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,5.5rem),1fr));align-items:stretch}
 html[data-acex-page=home] .acex-topbar nav .acex-theme-wrap{justify-self:start}
 .screen main:has(.pair-card){display:flex;align-items:safe center;justify-content:center;height:auto;overflow:visible;padding:clamp(10px,4vw,24px)}
 .screen .pair-card{min-width:0;max-width:100%;overflow-wrap:anywhere}
 .screen .pair-card svg{width:min(100%,270px);max-width:100%;height:auto;aspect-ratio:1;fill:black;background:white}
}
@media(max-width:310px){html[data-acex-page=home] .home-actions{grid-template-columns:minmax(0,1fr)}}

html[data-acex-page] .acex-topbar .acex-theme-wrap{margin-inline-start:auto;flex:none}
html[data-acex-page] .site-menu-toggle{background:#303237;color:white;border:1px solid #51535a;min-height:44px;padding:8px 14px;box-shadow:none}
html[data-acex-page] .acex-topbar #primaryNav[hidden]{display:none!important}
html[data-acex-page=home] section.home-intro{margin:clamp(14px,3vw,36px) 0 0;padding:clamp(19px,4vw,46px);display:grid;gap:16px 32px;background:#202125;color:#fff;border:1px solid #37383e;border-radius:16px;box-shadow:none}
html[data-acex-page=home] .home-intro h1{margin:0;color:#fff;line-height:1.2;letter-spacing:-.04em;font-size:clamp(28px,4vw,48px)}
html[data-acex-page=home] .home-intro p{margin:8px 0 0;color:#d0d0d3;font-size:clamp(14px,2vw,17px)}
html[data-acex-page=home] .home-intro .home-actions{width:100%;max-width:none;align-self:center}
html[data-acex-page=home] .home-intro .home-actions a{border:1px solid #66676d;min-height:48px}
html[data-acex-page=home] .home-intro .tv-action{border-color:#e8d1a6}
.account-actions{display:flex;align-items:center;gap:18px;border-top:1px solid #424349}
html[data-acex-page=home] .account-actions a{display:inline-flex;align-items:center;min-height:44px;color:#f6f4ee;text-underline-offset:4px}
html[data-acex-page=home] .tools-heading{margin:26px 0 12px;font-size:22px;letter-spacing:-.035em;color:var(--ax-ink)}
html[data-acex-page=home] section.links{margin-top:0;padding:0}
@media(min-width:780px){.home-intro{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr)}.account-actions{grid-column:1/-1}}
@media(max-width:1000px){
 html[data-acex-page] header.acex-topbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;gap:8px;min-height:60px;padding:8px clamp(10px,3vw,24px)}
 html[data-acex-page] .acex-topbar .acex-theme-wrap{display:block}
 html[data-acex-page] .acex-topbar #primaryNav:not([hidden]){flex:1 0 100%;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,7rem),1fr));gap:6px}
 html[data-acex-page] .acex-topbar #primaryNav a:not([hidden]){display:flex;justify-content:center;min-height:44px;align-items:center;background:#303136;color:#fff}
 html[data-acex-page] .acex-topbar #primaryNav a span{display:inline}
}
@media(max-width:480px){
 html[data-acex-page=home] section.links .menu-card{display:flex;align-items:center;gap:12px;padding:13px!important;min-height:68px}
 html[data-acex-page=home] section.links .menu-card i{flex:0 0 38px;width:38px;height:38px;margin:0}
 html[data-acex-page=home] section.links .menu-card>div{min-width:0;text-align:start}
}
