:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #111;
  background: #008080;
  font-synthesis: none;
  --surface: #c0c0c0;
  --light: #fff;
  --mid: #808080;
  --dark: #404040;
  --cell-size: 30px;
  --cell-font-size: 19px;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 28px 16px;
  display: grid;
  place-items: start center;
  background:
    radial-gradient(ellipse at 18% 24%, rgba(255,255,255,.11), transparent 36%),
    #008080;
}

button, input, select { font: inherit; }
button { color: inherit; }

.app-window {
  width: max-content;
  max-width: 100%;
  background: var(--surface);
  padding: 3px;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  box-shadow: 2px 2px 0 rgba(0,0,0,.3);
}

.title-bar {
  height: 27px;
  padding: 2px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  background: #000080;
  user-select: none;
}

.title-icon { font-size: 17px; color: #ffdf32; line-height: 1; }
.title-bar h1 { margin: 0; flex: 1; font-size: 14px; font-weight: 700; }
.window-control {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--surface);
  color: #111;
  font-size: 18px;
  font-weight: 700;
  line-height: 14px;
}

.menu-bar { display: flex; height: 27px; align-items: stretch; position: relative; z-index: 2; }
.menu { position: relative; }
.menu summary {
  list-style: none;
  height: 26px;
  padding: 5px 10px 4px;
  font-size: 13px;
  cursor: default;
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: #000080; color: #fff; }
.menu-list {
  position: absolute;
  left: 0;
  top: 25px;
  min-width: 190px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  box-shadow: 2px 2px 3px rgba(0,0,0,.3);
}
.menu-list button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 25px;
  padding: 3px 8px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
}
.menu-list button:hover, .menu-list button:focus-visible { color: #fff; background: #000080; outline: 0; }
.menu-list button span:not(.menu-check) { margin-left: auto; color: #555; }
.menu-list button:hover span:not(.menu-check) { color: #fff; }
.menu-list hr { border: 0; border-top: 1px solid var(--mid); border-bottom: 1px solid var(--light); margin: 3px 2px; }
.menu-check { width: 18px; font-weight: bold; }

.game-frame { padding: 10px; border: 3px solid; border-color: var(--mid) var(--light) var(--light) var(--mid); }
.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lcd {
  height: 44px;
  min-width: 72px;
  padding: 2px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080808;
  border: 2px solid;
  border-color: var(--mid) var(--light) var(--light) var(--mid);
}
.counter span {
  color: #f22;
  font: 700 34px/1 "Courier New", monospace;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 4px rgba(255,0,0,.22);
}
.face {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
  background: var(--surface);
  touch-action: manipulation;
}
.raised { border: 3px solid; border-color: var(--light) var(--dark) var(--dark) var(--light); }
.raised:active { border-color: var(--dark) var(--light) var(--light) var(--dark); }
.face span { transform: translateY(-1px); }

.board-frame {
  max-width: calc(100vw - 72px);
  overflow: auto;
  border: 3px solid;
  border-color: var(--mid) var(--light) var(--light) var(--mid);
  background: var(--surface);
  overscroll-behavior: contain;
}
.board {
  display: grid;
  width: max-content;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid;
  border-color: var(--light) var(--mid) var(--mid) var(--light);
  border-radius: 0;
  background: var(--surface);
  color: #111;
  font-size: var(--cell-font-size);
  font-weight: 700;
  line-height: 1;
  cursor: default;
  touch-action: manipulation;
}
.cell.revealed {
  border: 1px solid #888;
  background: #c0c0c0;
}
.cell.flagged { font-size: 18px; }
.cell.exploded { background: #f00; }
.cell.wrong-flag { color: #f00; }
.cell:focus-visible { outline: 2px dotted #000; outline-offset: -5px; z-index: 1; }
.n1 { color: #0000ff; }
.n2 { color: #008000; }
.n3 { color: #f00; }
.n4 { color: #000080; }
.n5 { color: #800000; }
.n6 { color: #008080; }
.n7 { color: #111; }
.n8 { color: #808080; }

.status-bar {
  min-height: 24px;
  padding: 4px 6px 1px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #333;
  font-size: 11px;
}

.system-dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 0;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--surface);
  color: #111;
  box-shadow: 3px 4px 14px rgba(0,0,0,.4);
}
.system-dialog::backdrop { background: rgba(0,0,0,.42); }
.system-dialog form { padding: 15px; }
.system-dialog h2 {
  margin: -15px -15px 16px;
  padding: 8px 12px;
  color: #fff;
  background: #000080;
  font-size: 15px;
}
.system-dialog label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 11px 0; font-size: 13px; }
.system-dialog input, .system-dialog select {
  width: 90px;
  min-height: 27px;
  padding: 3px 5px;
  border: 2px solid;
  border-color: var(--dark) var(--light) var(--light) var(--dark);
  background: #fff;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.dialog-actions button { min-width: 86px; min-height: 30px; padding: 3px 10px; background: var(--surface); }
.dialog-actions .primary { outline: 1px solid #111; outline-offset: 2px; }
.dialog-error { min-height: 16px; margin: 4px 0; color: #a00000; font-size: 12px; }
.score-level-label select { width: 160px; }
.score-list { margin: 8px 0 0; padding-left: 25px; font: 14px/1.8 "Courier New", monospace; }
.score-list li { padding-left: 4px; }
.info-content { font-size: 13px; line-height: 1.5; }
.info-content p:first-child { margin-top: 0; }
.notice {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 5;
  max-width: calc(100vw - 32px);
  padding: 9px 13px;
  transform: translate(-50%, 20px);
  opacity: 0;
  color: #fff;
  background: #222;
  border: 1px solid #fff;
  font-size: 13px;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.notice.visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.color-mode {
  --surface: #d0d0d0;
  --light: #f8f8f8;
  --mid: #707070;
  --dark: #333;
}

@media (max-width: 520px) {
  :root { --cell-size: 27px; --cell-font-size: 17px; }
  body { padding: 12px 6px; }
  .game-frame { padding: 7px; }
  .board-frame { max-width: calc(100vw - 46px); }
  .lcd { min-width: 66px; height: 40px; }
  .counter span { font-size: 31px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
