:root {
  --bg: #e6e7eb;
  --panel: #ffffff;
  --ink: #1b1631;
  --muted: #4d4368;
  --line: #bcb1e8;
  --line-strong: #c9beef;
  --accent: #673de6;
  --accent-2: #4f2fb4;
  --good: #4f2fb4;
  --bad: #3d2a7a;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: #e6e7eb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 10px;
}

.hero-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Hero shell (first section on tool pages). */
.container > section:first-of-type {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 15px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(19, 22, 28, 0.1);
}

h1 {
  margin: 0;
  font-size: clamp(1.62rem, 1.4vw + 1rem, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: #0f1114;
}

.subtitle {
  color: #4d4368;
  margin: 8px 0 0;
  max-width: 960px;
  font-size: 1rem;
  line-height: 1.52;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  font-size: 0.79rem;
  border: 1px solid #cabef2;
  border-radius: 999px;
  padding: 5px 10px;
  color: #4d4368;
  background: #f8f5ff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 11px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(19, 22, 28, 0.11);
  padding: 13px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.single-card {
  max-width: none;
  width: 100%;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
}

.tool-link {
  text-decoration: none;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cabef2;
  border-radius: 12px;
  padding: 11px;
  box-shadow: 0 8px 18px rgba(16, 38, 35, 0.08);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.tool-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(19, 22, 28, 0.12);
}

.tool-link h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  color: #2f2551;
}

.tool-link p {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.card h2 {
  margin: 0;
  font-size: 1.08rem;
  color: #2f2551;
}

.hint {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #414043;
  border-radius: 11px;
  padding: 10px 11px;
  font-size: 0.93rem;
  color: var(--ink);
  background: #ffffff;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: #673de6;
}

textarea:focus,
input:focus,
select:focus,
button:focus {
  outline: none;
}

textarea:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible,
.tool-link:focus-visible {
  border-color: #8f79eb;
  box-shadow: 0 0 0 3px rgba(143, 121, 235, 0.28);
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  padding: 3px;
  width: min(240px, 100%);
  height: 44px;
  min-height: 44px;
  border: 1px solid #414043;
  border-radius: 11px;
  background: #ffffff;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 8px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 8px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font: 0.9rem/1.45 Consolas, "Courier New", monospace;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 1px solid #cabef2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(19, 22, 28, 0.1);
}

button:active,
button:focus,
button:focus-visible {
  background: #4b2ea8;
  color: #fff;
  border-color: transparent;
}

button.primary {
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  background: #4b2ea8;
}

button.secondary {
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  background: #35206f;
}

.output {
  border: 1px solid #cabef2;
  border-radius: 11px;
  min-height: 92px;
  padding: 10px 11px;
  background: #ffffff;
  font: 0.89rem/1.46 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
}

.markdown-preview {
  border: 1px solid #cabef2;
  border-radius: 11px;
  min-height: 120px;
  padding: 12px;
  background: #ffffff;
  color: #2f2551;
  line-height: 1.55;
  white-space: normal;
  overflow: auto;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0 0 8px;
  line-height: 1.2;
}

.markdown-preview p {
  margin: 0 0 10px;
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 0 0 10px 20px;
  padding: 0;
}

.markdown-preview blockquote {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 3px solid #cabef2;
  background: #f8f5ff;
}

.markdown-preview pre {
  margin: 0 0 10px;
  padding: 10px;
  border-radius: 10px;
  background: #15171b;
  color: #eceef2;
  overflow: auto;
}

.markdown-preview code {
  font-family: Consolas, "Courier New", monospace;
}

.color-preview {
  display: block;
  width: 100%;
  height: 64px;
  border: 1px solid #cabef2;
  border-radius: 11px;
  background: #ffffff;
}

.map-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border: 1px solid #cabef2;
  border-radius: 11px;
  background: #f8f5ff;
  cursor: crosshair;
}

.map-hover-status {
  font-size: 0.83rem;
  color: #4d4368;
  font-weight: 600;
  margin-top: 2px;
}

.fun-history {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.history-chip {
  border-radius: 999px;
  border: 1px solid #cabef2;
  background: #f8f5ff;
  color: #4d4368;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.fun-dice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.fun-dice-tile {
  border: 1px solid #b0b4be;
  border-radius: 12px;
  min-height: 88px;
  padding: 8px 10px;
  background: #f6f7f9;
  display: grid;
  align-content: center;
  justify-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 16px rgba(19, 22, 28, 0.14);
  transform-origin: 50% 90%;
}

.fun-dice-tile .value {
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 800;
  color: #333843;
}

.fun-dice-tile .meta {
  margin-top: 5px;
  font-size: 0.77rem;
  color: #4f545f;
}

.fun-dice-tile.rolling {
  animation: dice-bounce 0.14s ease-in-out infinite alternate;
}

@keyframes dice-bounce {
  from { transform: translateY(0) rotate(-2deg); }
  to { transform: translateY(-5px) rotate(2deg); }
}

.die-face {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid #c1c5ce;
  background: #f4f5f7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 5px 12px rgba(20, 56, 50, 0.15);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
}

.die-face .pip {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #2d313a;
  align-self: center;
  justify-self: center;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.die-face .pos-1 { grid-area: 1 / 1; }
.die-face .pos-2 { grid-area: 1 / 2; }
.die-face .pos-3 { grid-area: 1 / 3; }
.die-face .pos-4 { grid-area: 2 / 1; }
.die-face .pos-5 { grid-area: 2 / 2; }
.die-face .pos-6 { grid-area: 2 / 3; }
.die-face .pos-7 { grid-area: 3 / 1; }
.die-face .pos-8 { grid-area: 3 / 2; }
.die-face .pos-9 { grid-area: 3 / 3; }

.fun-dice-tile.jackpot {
  border-color: #b8bcc6;
  background: #f1f2f5;
}

.fun-dice-tile.jackpot .value {
  color: #4b4f59;
}

.coin-stage {
  display: flex;
  justify-content: center;
  perspective: 900px;
  padding: 18px 0 8px;
  position: relative;
}

.coin-shadow {
  position: absolute;
  bottom: 8px;
  width: 98px;
  height: 18px;
  border-radius: 999px;
  background: rgba(24, 58, 73, 0.2);
  filter: blur(0.3px);
}

.coin.flipping + .coin-shadow,
.coin-stage .coin.flipping ~ .coin-shadow {
  animation: coin-shadow 1.05s cubic-bezier(0.14, 0.82, 0.2, 1);
}

@keyframes coin-shadow {
  0% { transform: scaleX(1) translateY(0); opacity: 0.42; }
  24% { transform: scaleX(0.72) translateY(3px); opacity: 0.23; }
  50% { transform: scaleX(0.56) translateY(5px); opacity: 0.15; }
  76% { transform: scaleX(0.76) translateY(3px); opacity: 0.28; }
  100% { transform: scaleX(1) translateY(0); opacity: 0.42; }
}

.coin {
  width: 116px;
  height: 116px;
  position: relative;
  transform-style: preserve-3d;
  border-radius: 50%;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid #b8bcc6;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.35), 0 12px 22px rgba(19, 22, 28, 0.18);
}

.coin-front {
  background: #d7dae1;
  color: #4c515b;
}

.coin-back {
  background: #c8ccd5;
  color: #3f4551;
  transform: rotateY(180deg);
}

.coin-heads {
  transform: rotateY(0deg);
}

.coin-tails {
  transform: rotateY(180deg);
}

.coin.flipping {
  animation: coin-spin 1.05s cubic-bezier(0.14, 0.82, 0.2, 1);
}

@keyframes coin-spin {
  0%   { transform: translateY(0) rotateY(0deg) rotateX(0deg); }
  18%  { transform: translateY(-34px) rotateY(780deg) rotateX(12deg); }
  40%  { transform: translateY(-66px) rotateY(1380deg) rotateX(7deg); }
  58%  { transform: translateY(-72px) rotateY(1680deg) rotateX(1deg); }
  76%  { transform: translateY(-38px) rotateY(2190deg) rotateX(-7deg); }
  90%  { transform: translateY(-10px) rotateY(2540deg) rotateX(-3deg); }
  96%  { transform: translateY(-4px) rotateY(2480deg) rotateX(3deg); }
  100% { transform: translateY(0) rotateY(2700deg) rotateX(0deg); }
}

.coin-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 120px;
  border: 1px solid #c1c5cf;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #4a4f59;
  background: #f3f4f6;
}

.coin-result.heads {
  color: #4b4f59;
  border-color: #b8bcc6;
  background: #eceef2;
}

.coin-result.tails {
  color: #3f4551;
  border-color: #bcc1cb;
  background: #e6e9f0;
}

.coin-result.pop {
  animation: pop-in 0.28s ease-out;
}

@keyframes pop-in {
  0% { transform: scale(0.9); opacity: 0.35; }
  100% { transform: scale(1); opacity: 1; }
}

.picker-display {
  min-height: 72px;
  border: 1px solid #b0b4be;
  border-radius: 11px;
  background: #f3f4f6;
  color: #333843;
  font-size: clamp(1.2rem, 2vw + 0.4rem, 1.9rem);
  font-weight: 800;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.picker-display.drawing {
  animation: picker-pulse 0.17s ease-in-out infinite alternate;
}

.picker-display.win {
  border-color: #b6bbc5;
  box-shadow: 0 0 0 3px rgba(111, 188, 154, 0.2);
}

.html-editor-preview {
  width: 100%;
  min-height: 420px;
  height: 100%;
  border: 1px solid #b0b4be;
  border-radius: 12px;
  background: #ffffff;
  display: block;
}

.html-editor-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
}

.html-editor-pane,
.html-preview-pane {
  display: grid;
  gap: 8px;
}

.html-editor-input {
  min-height: 420px;
}

.html-preview-pane label {
  margin-top: 2px;
}

@keyframes picker-pulse {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-2px) scale(1.02); }
}

.status {
  font-size: 0.84rem;
  font-weight: 600;
}

.status.ok { color: var(--good); }
.status.err { color: var(--bad); }

.ip-viewer-panel {
  gap: 12px;
}

.ip-actions {
  justify-content: flex-start;
}

.ip-section-title {
  margin: 2px 0 0;
  font-size: 1rem;
  color: #333842;
}

.ip-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 10px;
}

.ip-summary-item {
  border: 1px solid #b0b4be;
  border-radius: 12px;
  padding: 10px 11px;
  background: #fbfbfc;
}

.ip-summary-label {
  display: block;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #5a606b;
  margin-bottom: 5px;
  font-weight: 700;
}

.ip-summary-value {
  display: block;
  font-size: 1rem;
  color: #1f232b;
  word-break: break-word;
}

.ip-table-wrap {
  border: 1px solid #b0b4be;
  border-radius: 12px;
  overflow: auto;
  background: #ffffff;
}

.ip-table {
  width: 100%;
  border-collapse: collapse;
}

.ip-table th,
.ip-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid #dde0e6;
  vertical-align: top;
}

.ip-table tr:last-child th,
.ip-table tr:last-child td {
  border-bottom: none;
}

.ip-table th {
  width: 230px;
  min-width: 170px;
  color: #4f545f;
  font-size: 0.83rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.ip-table td {
  color: #2c313a;
  font-size: 0.9rem;
}

.ip-table td code {
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ip-empty {
  color: #7e848f !important;
  font-style: italic;
}

.tool-description h2 {
  margin: 0 0 8px;
}

.tool-description p {
  margin: 0 0 10px;
  color: #4a4f59;
  line-height: 1.58;
  font-size: 0.94rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-right {
    justify-content: flex-start;
  }
  .grid { grid-template-columns: 1fr; }
  .tool-list { grid-template-columns: 1fr; }
  .container { padding: 12px; }
  .row { grid-template-columns: 1fr; }
  .html-editor-layout { grid-template-columns: 1fr; }
  .html-editor-preview,
  .html-editor-input { min-height: 320px; }
  .ip-summary-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .ip-summary-grid { grid-template-columns: 1fr; }
  .ip-table th { width: 40%; min-width: 130px; }
}
