* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  color-scheme: light;
  --ink: #0d0d0d; --sub: #6b6b6b; --hint: #9a9a9a; --line: #ececec; --bg: #fff; --soft: #f6f6f6;
}
html, body {
  height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
#app { max-width: 460px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 22px 18px calc(20px + env(safe-area-inset-bottom)); }
.hidden { display: none; }

.hd h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.sub { color: var(--sub); font-size: 14px; margin-top: 10px; line-height: 1.55; }
.tabs { display: flex; gap: 4px; margin: 26px 0 14px; background: var(--soft); padding: 4px; border-radius: 12px; }
.tab { flex: 1; padding: 11px; border: none; background: transparent; border-radius: 9px; font-size: 14px; color: var(--sub); transition: .2s; }
.tab.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices button { padding: 26px 12px; border: 1px solid var(--line); background: #fff; border-radius: 14px; font-size: 16px; font-weight: 500; transition: .15s; animation: fadeUp .4s both; }
.choices button:active { transform: scale(.97); background: var(--soft); }
.choices button:nth-child(2){animation-delay:.04s} .choices button:nth-child(3){animation-delay:.08s} .choices button:nth-child(4){animation-delay:.12s} .choices button:nth-child(5){animation-delay:.16s} .choices button:nth-child(6){animation-delay:.2s}

.mtop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; min-height: 24px; }
.round { font-weight: 700; font-size: 15px; }
.count { color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.back { background: none; border: none; color: var(--sub); font-size: 14px; padding: 4px; }
#match { padding-top: 14px; }
.arena { flex: 1; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; min-height: 0; }
.card {
  flex: 1 1 0; min-height: 0; width: 100%; border: none; border-radius: 16px; overflow: hidden;
  position: relative; background: #eee;
  transition: flex-grow .4s cubic-bezier(.4,0,.2,1), opacity .4s ease, transform .4s ease;
}
.cimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left top; transform: scale(1.15); transform-origin: top left; }
.card::after { content: ""; position: absolute; inset: 0; border-radius: 16px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); pointer-events: none; transition: box-shadow .2s; }
.card .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--hint); font-size: 13px; z-index: 2; }
.card.enter { animation: cardIn .34s ease both; }
#cardB.enter { animation-delay: .05s; }
.card.win { flex-grow: 10; }
.card.win::after { box-shadow: inset 0 0 0 3px var(--ink); }
.card.lose { flex-grow: 0; opacity: 0; transform: translateY(-14px) scale(.94); }
.vs {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 46px; height: 46px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; z-index: 5; transition: opacity .2s;
}
.arena.chosen .vs { opacity: 0; }
.back { background: none; border: none; color: var(--sub); font-size: 20px; line-height: 1; padding: 4px 8px 4px 0; }

#reveal-body { flex: 1; display: flex; flex-direction: column; }
#reveal-body > * { animation: fadeUp .45s both; }
#reveal-body > *:nth-child(2){animation-delay:.06s} #reveal-body > *:nth-child(3){animation-delay:.12s} #reveal-body > *:nth-child(4){animation-delay:.18s} #reveal-body > *:nth-child(5){animation-delay:.24s}
.rv-img { width: 100%; height: 250px; object-fit: cover; border-radius: 16px; background: #eee; }
.rv-badge { display: inline-block; margin-top: 16px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 500; padding: 7px 13px; border-radius: 20px; }
.rv-title { font-size: 27px; font-weight: 700; margin-top: 12px; letter-spacing: -0.02em; }
.rv-addr { color: var(--sub); font-size: 14px; margin-top: 5px; }
.rv-desc { color: #3a3a3a; font-size: 14px; line-height: 1.65; margin-top: 16px; }
.btns { display: flex; gap: 10px; margin-top: auto; padding-top: 22px; }
.btn { flex: 1; padding: 16px; border-radius: 14px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; transition: transform .12s; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: #fff; color: var(--ink); }

.pl-group { margin-bottom: 24px; animation: fadeUp .4s both; }
.pl-label { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.pl-item { display: flex; gap: 12px; margin-bottom: 12px; text-decoration: none; color: inherit; transition: .12s; }
.pl-item:active { opacity: .6; }
.pl-item img { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: #eee; flex-shrink: 0; }
.pl-item .t { font-size: 15px; font-weight: 500; }
.pl-item .a { font-size: 12px; color: var(--sub); margin-top: 3px; line-height: 1.4; }
.pl-item .d { font-size: 12px; color: var(--hint); margin-top: 3px; }

.loading { color: var(--sub); text-align: center; padding: 48px 0; animation: pulse 1.2s ease-in-out infinite; }
.err { color: var(--sub); text-align: center; padding: 48px 0; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.fld { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; margin-top: 10px; background: #fff; }
.fld:focus { outline: none; border-color: var(--ink); }
.admin-keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.admin-keys button { padding: 8px 14px; border: 1px solid var(--line); background: #fff; border-radius: 20px; font-size: 14px; }
.admin-keys button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.admin-block { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-h { display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row { display: flex; align-items: center; gap: 10px; }
.admin-row img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: #eee; flex-shrink: 0; }
.admin-row-t { flex: 1; font-size: 14px; min-width: 0; }
.admin-row-t .sub { margin-top: 2px; }
.rm { width: 30px; height: 30px; border: none; background: var(--soft); border-radius: 50%; font-size: 16px; color: var(--sub); flex-shrink: 0; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.admin-card { border: none; background: none; padding: 0; text-align: left; }
.admin-card img { width: 100%; height: 80px; object-fit: cover; border-radius: 8px; background: #eee; }
.admin-card-t { font-size: 12px; margin-top: 4px; line-height: 1.3; }
#gallery { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; flex-direction: column; padding: 16px; overflow: auto; }
#gallery.hidden { display: none; }
.gal-head { background: #fff; border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.gal-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.gal-img { border: none; background: none; padding: 0; }
.gal-img img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; background: #eee; }
