:root {
  color-scheme: light;
  --screen-color: #ffffff;
  --page-background: #f4f5f7;
  --card-background: #ffffff;
  --text: #20242a;
  --muted: #626a74;
  --focus: #2458a6;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--page-background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button, input { font: inherit; }

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.control-card {
  width: min(100%, 390px);
  border: 0;
  border-radius: 14px;
  background: var(--card-background);
  box-shadow: 0 12px 34px rgba(24, 31, 40, .09);
  padding: clamp(24px, 6vw, 34px);
}

h1 { margin: 0 0 28px; font-size: clamp(1.6rem, 5vw, 2rem); line-height: 1.15; text-align: center; }
.field-group { display: grid; gap: 8px; margin-bottom: 20px; }
label, .field-label { font-size: .92rem; font-weight: 700; }

.color-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.color-card { min-width: 0; border: 0; border-radius: 9px; color: var(--text); background: #f0f2f5; display: grid; gap: 6px; padding: 8px; cursor: pointer; transition: background-color .18s ease; }
.color-card:hover { background: #e8ebef; }
.color-card[aria-pressed="true"] { background: #eef3fb; box-shadow: 0 0 0 2px rgba(36, 88, 166, .22); }
.color-card > span { height: 34px; border: 0; border-radius: 6px; background: var(--card-color); box-shadow: 0 2px 6px rgba(20, 25, 31, .16); transform: scale(1); transition: transform .18s ease, box-shadow .18s ease; }
.color-card:is(:hover, :focus-visible) > span { transform: scale(1.06); box-shadow: 0 5px 12px rgba(20, 25, 31, .22); }
.color-card small { overflow: hidden; color: var(--muted); font-size: .68rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.custom-color-control { width: 100%; min-height: 50px; border: 0; border-radius: 8px; color: var(--text); background: #f0f2f5; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 13px; cursor: pointer; font-weight: 650; text-align: left; }
.custom-color-control:hover { background: #e8ebef; }
.custom-color-preview { width: 32px; height: 32px; border: 0; border-radius: 7px; background: var(--screen-color); box-shadow: 0 2px 6px rgba(20, 25, 31, .16); }
.custom-color-icon { color: var(--muted); font-size: 1.2rem; }
.native-color-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

input[type="text"] {
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: #f0f2f5;
  padding: 13px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

small { color: var(--muted); font-size: .78rem; line-height: 1.4; }

.primary-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #244b7e;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:hover { background: #1d406d; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(36, 88, 166, .32); outline-offset: 2px; }
.fullscreen-option { display: flex; align-items: center; gap: 9px; margin-top: 15px; color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 650; line-height: 1.35; }
.fullscreen-option input { width: 17px; height: 17px; flex: 0 0 17px; margin: 0; accent-color: #244b7e; }
.escape-message { margin: 9px 0 0 26px; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.escape-message[hidden] { display: none; }
.message { min-height: 1.25em; margin: 12px 0 0; color: #9b2c2c; font-size: .82rem; line-height: 1.4; text-align: center; }
.message:empty { display: none; }

.exit-fullscreen {
  position: fixed;
  z-index: 10;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  background: rgba(0, 0, 0, .58);
  display: none;
  padding: 8px 11px;
  cursor: pointer;
  font-size: .75rem;
  font-weight: 700;
  opacity: .32;
}

.exit-fullscreen:hover, .exit-fullscreen:focus-visible { opacity: .92; }
html.is-color-fullscreen, html.is-color-fullscreen body { background: var(--screen-color); }
html.is-color-fullscreen .page-shell { display: none; }
html.is-color-fullscreen .exit-fullscreen { display: block; }
html.is-color-fullscreen .exit-fullscreen[hidden] { display: none; }

@media (max-width: 480px) {
  .page-shell { padding: 16px; }
  .control-card { border-radius: 12px; }
}

@media (max-width: 350px) { .color-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (prefers-reduced-motion: reduce) {
  .color-card, .color-card > span { transition: none; }
  .color-card:is(:hover, :focus-visible) > span { transform: none; }
}
