@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap');

body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.5s, color 0.5s;
    text-align: center;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: background-color 0.5s, color 0.5s;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

footer {
    padding: 1rem;
    font-size: 0.9rem;
    transition: background-color 0.5s, color 0.5s;
}

#wheel-container {
    position: relative;
    width: min(400px, 90vw);
    /* Use min() to cap size at 400px or 90vw */
    height: min(400px, 90vw);
    /* Keep aspect ratio */
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

#pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    transition: none;
    /* Remove transition to prevent animation issues */
}

canvas#wheel {
    width: 100%;
    /* Make canvas fill its container */
    height: 100%;
    /* Make canvas fill its container */
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2), inset 0 0 15px rgba(0, 0, 0, 0.1);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: block;
    position: relative;
}

#spinBtn {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, #8e44ad, #9b59b6);
    color: white;
    box-shadow: 0 5px 15px rgba(142, 68, 173, 0.4);
    transition: all 0.3s ease;
}

#spinBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(142, 68, 173, 0.5);
}

#spinBtn:active {
    transform: translateY(1px) scale(0.95);
    box-shadow: 0 2px 10px rgba(142, 68, 173, 0.4);
}

#spinBtn:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
}

#result {
    margin: 1.5rem 0;
    font-size: 1.8rem;
    font-weight: bold;
    min-height: 2rem;
}

#deleteControls {
    margin-top: 1rem;
    visibility: hidden;
}

#deleteControls button {
    margin: 0 0.5rem;
    padding: 8px 15px;
    border-radius: 5px;
    border: 1px solid;
    cursor: pointer;
}

#history {
    margin-top: 1.5rem;
    width: 90%;
    max-width: 400px;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.text-btn {
    background: none;
    border: none;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

#historyChart {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.chart-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.chart-label {
    flex-shrink: 0;
    width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

.chart-bar-container {
    flex-grow: 1;
    height: 20px;
    background-color: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.chart-bar {
    height: 100%;
    background-color: #8e44ad;
    /* Default bar color */
    border-radius: 3px;
    transition: width 0.3s ease-in-out;
}

.chart-count {
    margin-left: 10px;
    min-width: 20px;
    text-align: right;
}

dialog {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 500px;
    padding: 0;
    /* Remove padding from dialog itself */
}

.dialog-content {
    padding: 1.5rem 2rem;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

dialog h2 {
    margin-top: 0;
}

dialog button {
    display: block;
    margin: 1.5rem auto 0;
    padding: 10px 25px;
    border-radius: 20px;
    border: none;
    background-color: #8e44ad;
    color: white;
    cursor: pointer;
}

#itemImageUploadBtn {
    padding: 5px 15px;
    margin: 0;
    border-radius: 5px;
    flex-shrink: 0;
}

textarea#itemsInput {
    width: 100%;
    box-sizing: border-box;
    height: 150px;
    margin-bottom: 1rem;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 5px;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.5em;
    width: 100%;
    text-align: left;
    font-family: 'Noto Sans JP', sans-serif;
    -webkit-appearance: none;
    appearance: none;
}

/* Simple icons using text/pseudo-elements */
#settingsBtn::before {
    content: "⚙️";
}

#helpBtn::before {
    content: "❓";
}

#releaseNotesBtn::before {
    content: "📄";
}

#shareBtn::before {
    content: "🔗";
}

.icon-btn span {
    font-size: 1rem;
}

#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 100;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    opacity: 0;
    transition: opacity 0.5s, visibility 0.5s, bottom 0.5s;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

#qrcode {
    display: flex;
    justify-content: center;
    padding: 1em 0;
}


#releaseNotesContent {
    text-align: left;
}

#spin-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#stopBtn {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    background: linear-gradient(145deg, #c0392b, #e74c3c);
    color: white;
    box-shadow: 0 5px 15px rgba(192, 57, 43, 0.4);
    transition: all 0.3s ease;
}

#stopBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(192, 57, 43, 0.5);
}

#stopBtn:active {
    transform: translateY(1px) scale(0.95);
    box-shadow: 0 2px 10px rgba(192, 57, 43, 0.4);
}

#stopBtn:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
}

.settings-section {
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 10px;
}

.settings-section label {
    text-align: right;
    white-space: nowrap;
    /* ラベルが折り返されるのを防ぐ */
}

/* 設定ダイアログ内の入力要素がコンテナ幅に合わせて伸縮するようにする */
.settings-section>select {
    width: 50%;
}

.settings-section>select,
.settings-section>input[type="checkbox"] {
    justify-self: end;
}

/* Simple toggle switch */
input[type="checkbox"] {
    position: relative;
    width: 40px;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: #ccc;
    outline: none;
    border-radius: 20px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    transition: 0.5s;
    cursor: pointer;
}

input[type="checkbox"]:checked {
    background: #8e44ad;
}

input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 20px;
    top: 0;
    left: 0;
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: 0.5s;
}

input[type="checkbox"]:checked::before {
    left: 20px;
}

#game-status {
    margin-bottom: 1rem;
}

#scoreboard {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 600px;
}

.player-score {
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 100px;
}

.player-score.active {
    border: 2px solid #8e44ad;
    transform: scale(1.05);
}

.player-name {
    font-weight: bold;
}

.player-points {
    font-size: 1.2rem;
}

#gameSetupDialog input[type="number"],
#gameSetupDialog input[type="text"] {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
    width: 100%;
}

#playerNamesContainer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 1rem 0;
}

#gameSetupDialog div:last-child {
    display: flex;
    justify-content: space-around;
}

#cancelGameBtn {
    background-color: #7f8c8d;
}

#designItems {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 1rem;
}

.design-item-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 10px;
    align-items: center;
}

.design-item-row label {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.design-item-row input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 40px;
    height: 25px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
}

.design-item-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.design-item-row input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}