/* 你挑我玩 · 基础元素与共用组件
 *
 * 为什么单开这个文件：`js/ogames-ui.js`（19 个小游戏的界面，整段复用、一字未改）里的按钮写的是
 * `class="btn amber og-big"` / `btn green` / `btn red` / `btn ink` / `btn sky`，
 * 而 `.btn` 这套组件在一步一杯是定义在 **app.css** 里的，不在 ogames.css 里；
 * `util.js` 的 `token()` 吐出来的棋子用的是 `.tok` / `.tok.av`，同理。
 * 这两套要是没搬过来，小游戏里的按钮会变成一排没底色的字。
 * 所以这儿把它们**照原样搬过来**（只跟着 theme.css 换了色相），app.css / play.css 直接用，别重定义。
 *
 * 颜色和字体全在 theme.css，这个文件里只许 var()。
 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg0); color: var(--text); touch-action: manipulation; }
body {
  font-family: var(--body);
  font-size: 16px; line-height: 1.5;
  min-height: 100vh; min-height: 100dvh;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(130% 60% at 50% -8%, rgba(255, 93, 143, .20) 0%, transparent 62%),
    radial-gradient(100% 70% at 50% 8%, var(--bg1) 0%, var(--bg0) 70%),
    var(--bg0);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; padding: 0; }
input, textarea { font: inherit; -webkit-user-select: text; user-select: text; }
h1, h2, h3, .ttl { font-family: var(--title); font-weight: 800; margin: 0; letter-spacing: 2px; text-wrap: balance; }
.nw { white-space: nowrap; }
a { color: var(--hot2); }
img { -webkit-user-drag: none; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- 按钮（ogames-ui.js 直接用这一套，改之前先看它怎么用的） ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 10px 16px;
  border-radius: 16px; font-size: 18px; font-weight: 800;
  background: var(--panel3); color: var(--text);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .4);
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
.btn[disabled] { opacity: .38; pointer-events: none; }
.btn small { font-size: 13px; font-weight: 600; opacity: .75; }
.btn.hot { background: linear-gradient(180deg, var(--hot2), var(--hot)); color: #35061a; box-shadow: 0 4px 0 #a32a52; }
.btn.amber { background: linear-gradient(180deg, var(--amber2), var(--amber)); color: #37250a; box-shadow: 0 4px 0 #a8741c; }
.btn.green { background: var(--green); color: #052611; box-shadow: 0 4px 0 #2a8f61; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 4px 0 #9b2b36; }
.btn.violet { background: var(--violet); color: #fff; box-shadow: 0 4px 0 #5a43b0; }
.btn.ink { background: var(--panel3); color: var(--cream); }
.btn.ghost { background: transparent; border: 2px solid currentColor; box-shadow: none; opacity: .8; }
.btn.sm { min-height: 44px; font-size: 15px; border-radius: 12px; padding: 6px 12px; }
.btn.big { min-height: 64px; font-size: 24px; font-weight: 800; letter-spacing: 3px; border-radius: 20px; }
.btn.big small { letter-spacing: 0; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.ib {
  width: 44px; height: 44px; border-radius: 14px; background: rgba(50, 32, 84, .85);
  font-size: 20px; flex: none; display: grid; place-items: center; border: 1px solid var(--line);
}
.link {
  display: block; margin: 16px auto 0; color: var(--dim);
  text-decoration: underline; text-underline-offset: 4px; padding: 8px 14px;
}

/* ---------- 棋子 / 头像（util.js 的 token() 吐这个结构） ---------- */
.tok {
  --s: 28px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--c);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 70%, #000) 100%);
  color: #fff; font-weight: 800; font-size: calc(var(--s) * .48); line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(255, 255, 255, .55);
}
/* 老 WebView 不认 color-mix：带 var() 的声明不会回落到上一行，只能用 @supports 兜底 */
@supports not (color: color-mix(in srgb, red 50%, white)) {
  .tok { background: var(--c); }
}
.tok.av {
  background: radial-gradient(circle at 40% 35%, #fff8ff, #e6daf7 75%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35), inset 0 0 0 max(2px, calc(var(--s) * .085)) var(--c);
  overflow: hidden;
}
.tok.av img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .15)); }
.tok.av b { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
