/* ธีมเดียวกับ overlay ไลฟ์ (public/css/overlay.css ของ Overlay Studio): ฟ้าขาว · การ์ดขอบน้ำเงิน · ตัวเอียง */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  --navy: #0b2559;
  --blue-800: #123f9e;
  --blue-700: #1a56db;
  --blue: #2b7bff;
  --blue-400: #5ea2ff;
  --cyan: #22c7ff;
  --sky: #eaf3ff;
  --sky-2: #d3e6ff;
  --ink: #0f2a5c;
  --muted: #6a86b8;
  --live: #ff3b5c;
  --green: #12a150;
  --red: #e5294c;
  --line: #d3e6ff;
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --stripe: linear-gradient(90deg, var(--blue-700), var(--cyan) 45%, var(--blue));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
  background: radial-gradient(rgba(43, 123, 255, .16) 1.6px, transparent 1.9px) 0 0 / 22px 22px, linear-gradient(180deg, #f5f9ff, var(--sky));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- ชิ้นส่วนร่วม ---------- */
.badge {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, var(--blue-400), var(--blue-700)); border: 3px solid #fff; transform: rotate(-6deg);
  box-shadow: 0 4px 0 var(--navy), 0 8px 16px rgba(26, 86, 219, .35); font-size: 22px;
}
.tag { display: inline-block; background: var(--blue); color: #fff; font-weight: 700; letter-spacing: 4px; padding: 3px 10px 2px 13px; font-size: 12px; border-radius: 6px; white-space: nowrap; }
.title { font-weight: 700; font-style: italic; color: var(--blue-700); letter-spacing: .3px; text-shadow: 2px 2px 0 rgba(43, 123, 255, .16); }

.btn {
  border: 2px solid var(--sky-2); background: #fff; border-radius: 12px; padding: 7px 14px; font-weight: 700; color: var(--blue-700);
  box-shadow: 0 3px 0 var(--sky-2); transition: transform .08s, box-shadow .08s; text-decoration: none; display: inline-block;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--sky-2); }
.btn.pri { background: linear-gradient(145deg, var(--blue-400), var(--blue-700)); border-color: var(--blue-700); color: #fff; box-shadow: 0 3px 0 var(--navy); }
.btn.pri:active { box-shadow: 0 1px 0 var(--navy); }
.btn.red { color: var(--red); border-color: #ffd0d9; box-shadow: 0 3px 0 #ffd0d9; }
.btn.red.pri { background: linear-gradient(145deg, #ff6b86, var(--red)); border-color: #b5122f; color: #fff; box-shadow: 0 3px 0 #7d0b20; }

/* ---------- หน้า login ---------- */
.card {
  position: relative; max-width: 420px; margin: 7vh auto 20px; background: #fff; border: 4px solid var(--blue); border-radius: 22px;
  padding: 30px 24px 24px; text-align: center; box-shadow: 0 0 0 6px rgba(255, 255, 255, .85), 0 16px 34px rgba(26, 86, 219, .22);
}
.card::after { content: ''; position: absolute; right: -15px; top: 26px; bottom: 26px; width: 6px; border-radius: 3px; background: var(--cyan); }
.card .badge { width: 72px; height: 72px; border-radius: 20px; font-size: 36px; margin: 0 auto 14px; border-width: 4px; box-shadow: 0 6px 0 var(--navy), 0 14px 24px rgba(26, 86, 219, .35); }
.card h1 { margin: 10px 0 6px; font-size: 30px; }
.card p { margin: 6px 0; color: var(--muted); line-height: 1.65; font-size: 15px; }
.gbtn { display: flex; justify-content: center; margin: 22px 0 8px; min-height: 44px; }
.rules { text-align: left; font-size: 14px; background: var(--sky); border-radius: 14px; padding: 10px 14px 10px 30px; color: var(--ink); margin: 14px 0 0; }
.rules li { margin: 4px 0; }
.rules li::marker { color: var(--blue); }
.warn { background: #fff4e5; border: 2px solid #ffd7a8; color: #8a4b00; border-radius: 14px; padding: 12px 14px; text-align: left; font-size: 14px; line-height: 1.6; margin-top: 16px; }
.warn b { color: #6a3a00; }
.warn .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dev { margin-top: 16px; display: flex; gap: 8px; }
.dev input { flex: 1; min-width: 0; border: 2px solid var(--sky-2); border-radius: 12px; padding: 7px 12px; }

/* ---------- หน้าวาด ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.top { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px 9px; background: #fff; box-shadow: 0 4px 16px rgba(26, 86, 219, .1); z-index: 1; }
.top::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--stripe); }
.top .badge { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; border-width: 2px; box-shadow: 0 3px 0 var(--navy); margin-top: 2px; }
.top .who { flex: 1; min-width: 0; line-height: 1.15; }
.top .who .tag { font-size: 10px; letter-spacing: 3px; padding: 2px 7px 1px 9px; }
.top .who div { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; }
.top .who .title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who button { border: 0; background: none; color: var(--blue); font-size: 12px; padding: 0; font-weight: 600; white-space: nowrap; }
.pill { font-size: 13px; font-weight: 700; padding: 4px 11px 4px 9px; border-radius: 99px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.open { background: #ddf7e8; color: var(--green); }
.pill.open::before { animation: pulse 1.6s ease-out infinite; }
.pill.closed { background: #ffe3e8; color: var(--red); }
.pill.wait { background: var(--sky); color: var(--muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, .5); } 100% { box-shadow: 0 0 0 8px rgba(18, 161, 80, 0); } }
.link { border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; }

.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px; position: relative; }
.frame { position: relative; background: var(--navy); border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 4px var(--blue), 0 0 0 9px rgba(255, 255, 255, .9), 0 16px 34px rgba(26, 86, 219, .28); }
.frame img, .frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame img { object-fit: cover; opacity: .92; }
.frame canvas { touch-action: none; }
.frame .grid { position: absolute; inset: 0; background: radial-gradient(rgba(94, 162, 255, .28) 1.3px, transparent 1.5px) 0 0 / 22px 22px, radial-gradient(ellipse at 50% 40%, var(--blue-800), var(--navy) 75%); }
.frame .hint { position: absolute; inset: auto 0 10px; text-align: center; color: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 600; pointer-events: none; }
.veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11, 37, 89, .6); color: #fff; font-weight: 700; font-style: italic; font-size: 18px; text-align: center; padding: 20px; pointer-events: none; white-space: pre-line; }

.tools { position: relative; background: #fff; padding: 12px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: center; box-shadow: 0 -4px 16px rgba(26, 86, 219, .1); }
.tools::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--stripe); }
.colors { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--sky-2); padding: 0; transition: transform .1s; }
.sw.on { box-shadow: 0 0 0 3px var(--blue); transform: scale(1.12); }
.sw.custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw.custom input { position: absolute; inset: -6px; opacity: 0; width: 44px; height: 44px; cursor: pointer; }
.sizes { display: flex; gap: 5px; align-items: center; }
.sz { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--sky-2); background: #fff; display: grid; place-items: center; padding: 0; box-shadow: 0 3px 0 var(--sky-2); }
.sz i { display: block; border-radius: 50%; background: var(--ink); }
.sz.on { border-color: var(--blue); background: var(--sky); box-shadow: 0 3px 0 var(--blue); }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#eraser.on { background: var(--sky); border-color: var(--blue); box-shadow: 0 3px 0 var(--blue); }
.frame.erasing canvas { cursor: cell; }
.ring { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(11, 37, 89, .6); pointer-events: none; }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 9; box-shadow: 0 0 0 3px var(--blue), 0 8px 24px rgba(11, 37, 89, .35); max-width: 90vw; text-align: center; }

@media (orientation: landscape) and (max-height: 520px) {
  .app { flex-direction: row; flex-wrap: wrap; }
  .top { width: 100%; padding: 6px 10px 5px; }
  .top .badge { display: none; }
  .stage { padding: 10px; height: calc(100% - 50px); }
  .tools { width: 132px; height: calc(100% - 50px); flex-direction: column; overflow-y: auto; justify-content: flex-start; }
  .tools::before { right: auto; bottom: 0; width: 4px; height: auto; }
  .sizes { flex-wrap: wrap; justify-content: center; }
  .acts { flex-direction: column; }
}

@media (max-width: 470px) {
  .card { margin: 5vh 22px 20px 16px; }
}
